2017-02-03 56 views
0

我在ng-repeat中有Datatable,并希望能够为UI中的所有数据表生成唯一的dt-instance。这样我就可以拥有每个表的唯一实例。这是我与正在发生的事情带有角度数据表的唯一DT实例

 <li ng-repeat="batch in vm.batches"> 
       <div ng-show="batch.opened.submitted"> 
         <table datatable="ng" class="table table-condensed dataTable" dt-options="vm.dtOptions" dt-instance="**I WANT TO BE ABLE TO SET THIS TO SOMETHING UNIQUE**"> 
           <thead> 
             <tr> 
               <th></th>                
             </tr> 
           </thead> 
            <tbody> 
             <tr ng-repeat="item in batch.PricingItems"> 
               <td> 
                 <a href="javascript:;" ng-click="childInfo(item, batch.dtInstance, $event)" title="Click to view more"> 
                  <i class="glyphicon glyphicon-plus-sign"></i> 
                 </a> 
                </td>               
             </tr> 
            </tbody> 
         </table> 
        </div> 
      </li> 

回答

0

你可以把它唯一通过传递ng-repeat$index值模板文件。

<li ng-repeat="batch in vm.batches track by $index"> 
    <div ng-show="batch.opened.submitted"> 
     <table datatable="ng" class="table table-condensed dataTable" dt-options="vm.dtOptions" dt-instance="$index"> 
+0

但因为$指数无.DataTable是不是一个对象,所以,如果我想访问的数据表在我的控制器,如dtInstance.DataTable,数据表将是不确定的 –