1
動的に生成する要素(ボタン)がある場合、またはinit AngularJSの後に生成する要素がある場合、AngularJSの問題が発生しました。下のソースコードは、ng-click属性をトリガーできないボタンを示しています。 AngularJSを起動した後にAngularJS属性をトリガできるアイデア。ありがとう。initの後にAngularJS属性を持つHtml要素AngularJS
OperationFormatter: function (value, row) {
var operations = [];
operations.push('<button class="btn-mini glyphicon glyphicon-edit" ng-
click="myFunc()" title="Shared_Edit"></button>');
return operations.join(' ');
// This function only can execute after init the AngularJS due to certain
conditions.
}
$(function() {
MyCtrl();
})
function MyCtrl($scope) {
var app = angular.module("appAffiliateInfo", []);
app.controller("ctrlBankInfo", function ($scope) {
$scope.myFunc = function() {
alert('ok');
};
});
};
オペレーションフォーマッタは、角度のあるアプリケーションコード内か外にありますか?それ以外の場合は、まったく正しいアプローチではありません。それが内部にある場合は、$ compileを使用して、domに動的に追加される要素をコンパイルすることができます – Shantanu