-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Instantiate only one directive playing a particular role #3011
Comments
I think we should go with Proposal 1 of using
NOTE: We could optionally have a concept of priority, but with have bad examples from AngularJS v1 where we did have priority and it was difficult to come up with absolute scale for priorities across libraries. |
I like the first proposal, but I think we can make it more inclusive. What about:
Rules:
|
any movement in solving this issue? |
Any plans for Angular 2.1? Plain HTML5 forms are just painfull (e.g. |
I was reading the code that is where I came across this issue/suggestion, just curious what are the plans for this feature @vsavkin @mhevery @IgorMinar @vicb |
FYI, for my particular problem I was able to find a workaround: |
@vsavkin Is the issue relevant? |
For our team this issue is relevant, because we have a common value accessor in the commons module and some specific one in the application module. We want to overwrite the common value accessor with a more specific selector without having the requirement to exclude all specific value accessors in the common module. |
I'm going to close this issue, as we believe this problem is well suited to being solved in userspace. It's a separate question whether |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
We need to provide a way to tell the compiler not to instantiate a directive when there is another, more specialized, directive that does the same job.
Imagine we have a default value accessor directive used by forms.
Now, let's add a more specialized value accessor that can handle checkboxes.
In the following template I would like the first input to use DefaultValueAccessor, and the second input to use CheckeboxValueAccessor.
Unfortunately, the second input will end up having two value accessors. So this approach does not work.
What we have to do right now is to write mutually exclusive selectors that look like this:
Even though this approach is not elegant, it sort of works when one person/team provides a set of directives. If, however, I would like to add a third-party value accessor, I will end up having the same problem: I will have two value accessors created for the same element.
Proposal 1
Have a mechanism to tell the compiler that all value accessors play the same role. So the compiler can instantiate only one for each element. The compiler can take the last directives from the list of directives that matches a element.
We can also try to unify this concept with
exportAs
, because the role and the local name should always match.Proposal 2
Have a generic mechanism for a directive to specify a compile-time predicate to determine if it should be instantiated.
This can be useful for other scenarios. For example, if you want to make sure that the dom structure matches some required shape. This may not work with Dart transformers.
@mhevery @tbosch @jeffbcross
The text was updated successfully, but these errors were encountered: