I have this directive that removes unwanted elements from a list, repeated by an ng-repeat
.
However i have a hard time getting the priority working, by default i know the ng-repeat that repeats my wanted and unwanted elements is 100, so in my directive i set restriction to a value below that so ensure ng-repeats has finished before looking for unwanted elements.
This is (still) not working :
myApp.directive('imageContainerRemoval', function() {
return {
priority: 999,
restrict: 'E',
link: function postLink (scope, element, attrs) {
From Angular Docs :
Directives with greater numerical priority are compiled first. Pre-link functions are also run in priority order, but post-link functions are run in reverse order . The order of directives with the same priority is undefined. The default priority is 0.
As the link
function is just a shortcut for the post-link
function, I guess instead you have to use the pre-link
function or reverse the priorities.
NOTE: The priority of ngRepeat is 1000 by default.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.