-
Notifications
You must be signed in to change notification settings - Fork 27.5k
stacked directive not executed if ng-if is present #8748
Comments
BREAKING CHANGE: The `replace` flag for defining directives that replace the element that they are on will be removed in the next major angular version. This feature has difficult semantics (e.g. how attributes are merged) and leads to more problems compared to what it solves. Also, with WebComponents it is normal to have custom elements in the DOM.
That looks strange. ngIf really seems to swallow the other directive when replace=true. |
Yes. As you may imagine, my test case is a boiled-down example of what we're really facing. The use case is augmentation of an existing AngularJS application that is created by a third party. We rely on it heavily. Imagine that a third-party, let's say the vendor of a web application, creates the template-expanding directive. We don't control the vendor's code. The vendor provides the option to include custom JavaScript (for widgets, modifications, etc. etc.), JavaScript code which we do control. Our goal is now to enhance/modify the existing UI, for which we use stacked directives that carry the same name as the vendor's original directives. The interaction of those directives with the original (vendor-provided ones) needs to be well-defined and should not depend on what is in the template, even if replace=true is used, IMO. |
this is not related to the fact that there are multiple directives that apply to the same element, in fact, if you move the
|
So does this mean that directives that use 'replace=true' cannot be stacked? In our actual use case, the vendor directive uses replace=true. We cannot add other directives in the way you suggest (unless we completely override the vendor directive, which would make stacking less practical). |
there are many things you can still do:
Without some extra information, it is impossible to know what the best solution would be. Now, this is getting out of topic, so I think it is better to continue the conversation in StackOverflow |
When stacking directives on top of a template-expanding directive, the stacked directive may or may not be executed depending on the template. The presence of ng-if, in particular, appears to influence whether stacked directives are applied. Occurs in 1.2.20 and 1.3.0beta16
See pluncker: http://plnkr.co/edit/7gs4uRP5PDHRKj6MLu2s
The text was updated successfully, but these errors were encountered: