I'm looking to understand the expected behavior of angular directives when a page is loaded once then returned to using routing. If I have a the directive below on a page, the debugger line is reached when the page is first loaded. When I navigate away from that page to another page with a different controller, then return to the original page with the directive, the directive doesn't load. Is that the expected behavior when dealing with different controllers? Or should the directive link be called every time the page is 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 the page like this
<directive1 id="mydirective" style="height:100%;"></directive1>
The flow is like this
pg1.htm(directive)/controller1 --> pg2.htm/controller2 --> back to pg1.htm(directive)/controller1