我已經創建了一些基本指令。它工作得很好,如果我用它在HTML中,某些對象文件在應用程序生命週期中創建的對象中的指令不起作用
<some-directive some-data="123"></some-directive>
但如果我動態加載該對象到我的網頁:
//getting html source as a string, then appending it to DOM:
elem.html("<some-directive some-data='123'></some-directive>");
該指令不工作(被正確添加對象到DOM)
app.directive('someDirective', function (notes, parts) {
return {
restrict: 'AE',
scope: {
someData: '='
},
link: function (scope, elem, attrs) {
console.log("directive fired");
}
};
});
我能做些什麼才能使它正常工作?
不會不使用'$ compile'工作...不知道它在那裏編譯 – charlietfl