angularjs - Angular JS directive loading explained -
i'm looking understand expected behavior of angular directives when page loaded once returned using routing. if have directive below on page, debugger
line reached when page first loaded. when navigate away page page different controller, return original page directive, directive doesn't load. expected behavior when dealing different controllers? or should directive link
called every time page loaded regardless?
app.directive('directive1', function () { return { restrict: 'e', replace: true, template: '<div></div>', link: function (scope, element, attr) { debugger; console.log('directive loaded'); } } });
it's on page this
<directive1 id="mydirective" style="height:100%;"></directive1>
the flow this
pg1.htm(directive)/controller1 --> pg2.htm/controller2 --> pg1.htm(directive)/controller1
since spa, moving inside angularjs app, directive not loaded everytime. once refresh page loaded.
Comments
Post a Comment