Angular `ng-click` not working in DataTables table row

后端 未结 3 807
悲哀的现实
悲哀的现实 2021-01-13 15:40

I have an angular application that is also using jquery.dataTables. When I use datatables to build a dynamic table with th

3条回答
  •  无人及你
    2021-01-13 16:08

    For those who wants to access $compile and $scope from outside angular and apply it to the datatable rows.. here I have the answer

    "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
    
      var $injector = angular.element(document.body).injector();
      var scope = angular.element(document.body).scope();
                
      $injector.invoke(function($compile) {
        $compile(nRow)(scope);
      });
                
    },

    with this you can add every ng event to the row and it will work! :D

提交回复
热议问题