0

我有多个选项卡,每个选项卡里面都有角度 ui-grid。每个网格应显示不同的数据。但是我面临的问题是,在一个选项卡中,数据在页面加载时进入网格,但在另一个选项卡中,ui-grid 本身没有加载。不明白是什么问题。请帮忙。以下是代码示例:

<uib-tabset class="nav">
<uib-tab heading="User">
<div ng-include="'./public/partials/tabs/user.html'">
</div>
</uib-tab>

<uib-tab heading="Notes">       
<div ng-include="'./public/partials/tabs/notifications.html'">
</div>
</uib-tab>

<uib-tab heading="Assets">
<div ng-include="'./public/partials/tabs/assetsList.html'"></div>
</uib-tab>
<uib-tab heading="Audit Logs">
<div ng-include="'./public/partials/tabs/audit.html'" >
</div>
</uib-tab>
</uib-tabset>

标签的HTML:

<div class="container-fluid">
<form name="assetsForm" novalidate class="form-horizontal">
<div class='container-fluid containerborder'>
<br>
<!--creating table-->
<div data-ui-grid="assetsOptions" data-ui-grid-pagination></div>
</div> 
</form>
</div>

<div class="container-fluid">
<form name="userForm" novalidate class="form-horizontal">
<div class='container-fluid containerborder'>
<br>
<!--creating table-->
<div data-ui-grid="userOptions" data-ui-grid-pagination></div>
</div> 
</form>
</div>

控制器部分:

$scope.data = [
  { name: 'Alex', car: 'Toyota' },
  { name: 'Sam', car: 'Lexus' },
  { name: 'Joe', car: 'Dodge' },
  { name: 'Bob', car: 'Buick' },
  { name: 'Cindy', car: 'Ford' },
   ];

$scope.userOptions = {
  data: 'data',
  paginationPageSizes: [5, 10, 25],
  paginationPageSize: 5,
  columnDefs: [
   {name: 'name'},
   {name: 'car'}
     ]
    };

$scope.assetsData = [
     { table: 'Brian', class: 'Audi' },
     { table: 'Malcom', class: 'Mercedes Benz' },
     { table: 'Dave', class: 'Ford' },
     { table: 'Stacey', class: 'Audi' },
     { table: 'Amy', class: 'Acura' },
     { table: 'Scott', class: 'Toyota' },
     { table: 'Ryan', class: 'BMW' },
   ];

   $scope.assetsOptions = {
     data: 'data',
     paginationPageSizes: [5, 10, 25],
     paginationPageSize: 5,
     columnDefs: [
       {name: 'table'},
       {name: 'class'}
     ]
    };  
4

1 回答 1

0

如果一个网格在页面加载时加载而其他网格未加载,则基本上意味着 A) 其他选项卡在页面加载时未初始化 B) 网格初始化代码应在选项卡切换而不是页面加载 C) 文件或数据在指定时不可用地点。

我希望这将有所帮助。

于 2015-12-05T05:49:12.743 回答