This behaviour is intended, ng-init purposely runs only once.
When you look at the ngInit directive, (https://github.com/angular/angular.js/blob/master/src/ng/directive/ngInit.js) you can see that the $eval
uation of the script passed to ng-init is done in the compile
function instead of the link
function.
var ngInitDirective = ngDirective({
priority: 450,
compile: function() {
return {
pre: function(scope, element, attrs) {
scope.$eval(attrs.ngInit);
}
};
}
});
Compile is only executed only once in your applications lifetime, whereas link is executed every time the directive is link
ed to an element/your document.