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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -