Angularjs 不动态渲染的角度指令
我将angular指令用于jquery datatables,在mRender函数中,我使用以下代码呈现行操作: datatables mRender函数: 指令代码:Angularjs 不动态渲染的角度指令,angularjs,render,jquery-datatables,directive,Angularjs,Render,Jquery Datatables,Directive,我将angular指令用于jquery datatables,在mRender函数中,我使用以下代码呈现行操作: datatables mRender函数: 指令代码: 这个问题已经老掉牙了,但问题来了。。。。对于我的名为spinner的指令: { className: 'spinner-control', orderable: false, data: null, render: function (data, type, row, meta) {
这个问题已经老掉牙了,但问题来了。。。。对于我的名为spinner的指令:
{
className: 'spinner-control',
orderable: false,
data: null,
render: function (data, type, row, meta) {
return '<spinner ng-model="accounts['+meta.row+'].alloc" ng-format="percentage" width="75px" step="0.5"></spinner>';
}
}
将标记添加到dom时是否使用$complie$编译电子显微镜;可能重复的是,$compilemarkup2$scope返回[object object]$compilemarkup2$scope.html返回nullmRender函数需要html字符串标记而不是元素object一个建议可能是一个jQuery自定义事件,该事件由DIV的委托事件处理程序触发,并在设置数据表的jQuery自定义事件内部指令中操纵作用域。我已经使用了很多数据表,而且有角度……但还从来没有一起使用过
app.directive('rowActions', function () {
return {
restrict: 'A',
replace: true,
template: '<button data-ng-click="action()"></button>',
scope: {
action: "&"
}
};
});
{
className: 'spinner-control',
orderable: false,
data: null,
render: function (data, type, row, meta) {
return '<spinner ng-model="accounts['+meta.row+'].alloc" ng-format="percentage" width="75px" step="0.5"></spinner>';
}
}
$('.spinner-control').each(function(){
var innerHTML = $(this);
console.log("InnerHTML", innerHTML);
var html = $compile(innerHTML)($scope);
console.log("HTML", html);
$(this).innerHTML = '';
$(this).append(html);
});