javascript - AngularJS ng-include in direcive link doesnt work -
i have created directive link function contains element ng-include
. element ng-include
doesn't work. know why doesn't work?
app.directive('helloworld', function () { return { link: function (scope, elem, attrs) { var div = document.createelement('div'); div.setattribute('ng-include', "page2.html'"); elem.append(div); } }; });
you added didn't compiled it, after compile working.
app.directive('helloworld',['$compile', function ($compile) { return { link: function (scope, elem, attrs) { var div = document.createelement('div'); div.setattribute('ng-include', "'page2.html'"); elem.append(div); $compile(div)(scope); } }; }])
here link
Comments
Post a Comment