georgiy.zhuravlev
georgiy.zhuravlev

Reputation: 475

how to append directive restrict='A' to existing element

There is a need to append a custom directive which is restricted to 'A' (attribute) to some of the instances of others directives (the second one, e.g.) after it was rendered using ng-repeat.

<some-directive ng-repeat="item in vm.items"></some-directive>

that 'A'-directive is derived from uib-popover, but I suppose solution for pure uib-popover will also work. Also, it would be great to safely remove than appended popovers later.

Any suggestions how to implement it?

Upvotes: 0

Views: 43

Answers (1)

Pankaj Badukale
Pankaj Badukale

Reputation: 2054

You can do it in this way::

Create custom directive with priority more than ng-repeat priority....

ng-repeat has 1000 priority.

angular.module('x').directive('customDir', function() {
    return {
        priority: 1001, // as ng-repeat has priority level 1000
        restrict: 'A',
        compile: function () {
            return function () {...}
        }
    }
})

Uses::

<some-directive ng-repeat="item in vm.items" custom-dir ></some-directive>

Upvotes: 1

Related Questions