如何使用angularjs动态地在数据表中添加ng-click?

时间:2015-08-26 05:40:58

标签: jquery angularjs angularjs-directive angularjs-ng-click

我正在尝试动态添加数据表中的锚标记链接,添加了标记,但是ng-click事件无效。

我的angularjs代码:

listApp.controller('mylistctr', ['$scope', '$timeout', '$compile', function ($scope, $timeout, $compile) {
 $timeout(function () {
    if (!$.fn.dataTable) return;

    dtInstance1 = $('#datatable1').dataTable({
        'paging': true,  // Table pagination
        'ordering': true,  // Column ordering 
        'info': true,  // Bottom left status text
        sAjaxSource: '/AutomationFX/api/clusters/phones/phonelist',
        aoColumns: [
          { mData: 'column1' },
          { mData: 'column2' },
          { mData: 'column3' },
          { mData: 'column4' },
          { mData: 'column5' }
        ], "aoColumnDefs": [{
            "aTargets": [4],
            "mRender": function (data, type, full) {
                return '<a ng-click="openWindow('+data+')"><img src="app/img/a.png"/></a>';

            }
        }]
    });

});
});

我的HTML

<div class="table-responsive">
                <table id="datatable1" class="table table-striped">
                    <thead>
                        <tr></tr>
                    <th style="width:15%">Name</th>
                    <th style="width:15%">LastName</th>
                    <th style="width:15%">Contact</th>
                    <th style="width:45%">Desc</th>
                    <th style="width:10%">Action</th>
                    </thead>
                    <tbody></tbody>
                </table>
            </div>

到目前为止,我发现我必须编译动态html,但我还没有找到正确的解决方案。

0 个答案:

没有答案
相关问题