I have created a custom directive with a priority of 1000. In the directive's compile function I am removing ng-if
from the element. My assumption is that since ng-if
has a lower priority of 600, it should not get compiled.
app.js
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
});
app.directive('myDirective', function(){
return {
priority: 1000,
compile: function(element){
angular.element(element).removeAttr('ng-if').removeAttr('my-directive1');
}
};
});
app.directive('myDirective1', function(){
return {
compile: function(){
console.log('in mydirective1');
}
};
});
index.html
<div my-directive ng-if="false" my-directive1>
This div should be visible.
</div>
I have created another directive to check if my understanding of priority is correct. myDirective
is successfully removing myDirective1
, but not ngIf
.
Following is the plunker link: