I have developed a unique custom directive with a priority of 1000. Within the compile function of the directive, I am removing the ng-if
attribute from the element. My belief is that since ng-if
has a lower priority of 600, it should not undergo compilation.
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>
To test my assumption about priorities, I have created another custom directive. While myDirective
successfully removes myDirective1
, it does not remove ngIf
.
Here is the link to the Plunker for further exploration: