简体   繁体   English

ng-click在响应性角度数据表中不起作用

[英]ng-click doesn't work in responsive angular-datatables

I'm trying to click on a element of my table in a responsive way, but it doesn't work. 我正在尝试以响应方式单击表中的元素,但是它不起作用。 It seems that ng-click doesn't work perfectly.. ng-click似乎无法正常工作。

this is my html table: 这是我的html表:

<table id="listadifferite" datatable="ng"  dt-options="myController.dtOptions"
   class="table table-bordered table-striped" cellspacing="0" width="100%">
   <thead>
      <tr>
         <th>Col1</th>
         <th>Col2</th>
         <th>Col3</th>
         <th>Col4</th>
      </tr>
   </thead>
   <tbody>
      <td data-dt-column="{{differite.idDif}}_0" class="text-center">Prova</td>
      <td data-dt-column="{{differite.idDif}}_1" class="text-center">
         <a ng-click="controllerDif.mostraDettaglio(differite)"><i class="fa fa-search-plus"></i></a>
      </td>
      <td data-dt-column="{{differite.idDif}}_2" class="text-center">Prova</td>
      <td data-dt-column="{{differite.idDif}}_3" class="text-center">Prova</td>
      </tr>
   </tbody>
</table>

and this is dtOptions in myController: 这是myController中的dtOptions:

self.dtOptions = DTOptionsBuilder.newOptions()
 .withPaginationType('full_numbers')
 .withOption('responsive', {
  details: {
   type: 'column',
   target: 0
  }
 })

another similar issue here: https://github.com/l-lin/angular-datatables/issues/552 另一个类似的问题在这里: https : //github.com/l-lin/angular-datatables/issues/552

adding this function to the controller fixed it : 添加此功能到控制器修复它:

 function renderer(api, rowIdx, columns) {
                var data = $.map( columns, function ( col, i ) {
                     return col.hidden ?
                         '<li data-dtr-index="'+col.columnIndex+'" data-dt-row="'+col.rowIndex+'" data-dt-column="'+col.columnIndex+'">'+
                              '<span class="dtr-title">'+
                                  col.title+
                            '</span> '+
                            '<span class="dtr-data">'+
                                col.data+
                           '</span>'+
                       '</li>' : 
                       '';
                   }).join('');
                   return data ?
                       $compile(angular.element($('<ul data-dtr-index="'+rowIdx+'"/>').append( data )))($scope) :  
                        false;
               }

and add responsive option 并添加响应选项

 .withOption('responsive', {
              details: {
                  renderer: renderer
              }
         })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM