4
우선 순위가 1000 인 사용자 지정 지시문을 만들었습니다. 지시문의 컴파일 함수에서 요소에서 ng-if
을 제거합니다. 내 가정은 ng-if
은 600의 우선 순위가 낮으므로 컴파일되지 않아야한다는 것입니다.ngif가 우선 순위 레벨을 무시하는 이유는 무엇입니까?
내가 우선 순위에 대한 이해가 정확한지 확인하기 위해 다른 지시를 만든 index.html을
<div my-directive ng-if="false" my-directive1>
This div should be visible.
</div>
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');
}
};
});
app.js. myDirective
은 myDirective1
을 성공적으로 삭제하지만 ngIf
은 삭제하지 못했습니다.
https://plnkr.co/edit/86mauwbt5I2aV4aoySpz?p=preview
감사합니다. – Vaibhav