-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(docs): remove statement about isolated scopes and ngModelController #4043
Conversation
Thanks for the PR!
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
My real name is "Christoph Burgdorf" and I signed the CLA before. |
Looks good. Thanks, @cburgdorf! |
Well, while the wording is misleading the sentiment is correct. What the docs are saying is that if, inside the template of a directive that has isolated scope, you try to bind an input (using ng-model) to a value (not a property on an object) that is mapped through the isolated scope of the directive, then changes to that value inside the isolated scope will not be propagated to the outer scope. |
So it is still an issue, that has been a gotcha for quite a few people of the last few months. The solutions are
How about we reword it rather than remove it? |
The last item being the kind of solution used in the date picker. |
I see! Thanks for clarifying. It should be really reworded then. But as I'm still trying to wrap my head around it, I'm probably not the best candidate to come up with a great suggestion :) |
Ok, I think we should not only reword but also provide plunkrs with examples to the different approaches. I'm currently getting into the topic anyway so I'm willing to come up with something soon. |
@cburgdorf - Hope you don't mind but, in that case, I'll close this PR and either you or I will open a new one with better wording. |
Sure, that's fine! |
I had a play around with this issue and actually I don't think my comments earlier are necessarily correct. |
That's certainly going into the right direction. However, I still find the wording confusing. "you cannot require |
@cburgdorf @petebacondarwin Just for the records, regarding your rewording, what if one does something like scope: {
ngModel: '='
} This actually would fill the gap right? |
@PascalPrecht I don't really get what you mean with your comment. Should this be a possible solution to the problem? Because then I have to say that the possible workarounds a slightly more involved ;-) But there are better tickets to discuss about the issue itself (e.g. #1924). "Note that if you have a directive with an isolated scope, you cannot require It's like, "hey, stop working on this custom directive, it will never work together with a form." But that's actually not true. There are solutions/workarounds, we just need to point that out properly. |
@cburgdorf Pete described in his commit, that the model will not be updated on the outer scope, but when setting up a bi-directional data binding with Just a thought. |
@PascalPrecht Ok, I think what you meant to say was rather This seems to work fine for the example given by @petebacondarwin. Here is a working plunkr: http://plnkr.co/edit/pUZI3f?p=preview I was also able to use it for my custom directive where I previously used a slightly different approach but this one seems to be even easier. But I'm pretty sure there must be something we are missing. It just can't be that easy in all circumstances, otherwise what's the deal about the FUD haha ;-) @petebacondarwin can you shed some more light on the topic? |
@PascalPrecht Or, well you can have it your way, too ;-) http://plnkr.co/edit/Wn1qga?p=preview So, what's the deal? |
Yep , would like to know too what's wrong with |
It's obviously possible to use ngModelController in a directive that uses an isolated scope, so this sentence seems to be outdated.
E.g. the bootstrap datepicker does that:
https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L131