-
Notifications
You must be signed in to change notification settings - Fork 6.8k
API References should be painfully explicit about two-way binding. #3364
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
Comments
@jrood Since there are a lot of components how would you suggest doing this? |
Thanks @M-a-c , I was imagining an example in each component. |
@jroodHNTB so would that show every @input method you could do, or just explain how it is useful and leave the rest up to the user? |
(sorry for switching between jrood and jroodHNTB accounts) |
For the button component is there even anything that can be two way bound? https://material.angular.io/components/component/button |
It doesn't look like there is anything on a button that can be two way bound. An example on Tabs under MdTabGroup is that there is an input |
@jrood so that does say "Output to enable support for two-way binding on Also I am trying to think of how best to implement this. I'm trying to avoid the use of gulp if possible. How exactly do you envision it looking? |
Hmm, now that I'm thinking more about this, it might not be necessary to add a new line, but just to actually use the syntax in the explanation "Output to enable support for two-way binding via For the two-way binding syntax, square braces are always on the outside and parenthesis on the inside like this They're using gulp to build the docs? Hmm I don't know if I can help you with that. |
@M-a-c Unfortunately get and set methods do not imply two-way binding, they might just be used internally within the component. I don't have a strong opinion about whether it's on both. Just the output is probably fine. |
So how can you say for sure if something is two way bound? |
It has to have an @input and then an @output that has the same name as the @input plus 'Change'. So you could have an @input called 'salmongrass' and an @output called 'salmongrassChange', and that would mean you could use the two-way binding syntax |
so I looked through the components and core.. All I could find was MdTabGroup with two way binding, that's seriously the only component with two way binding that i could find. |
@jelbourn can you close this issue? |
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. |
Currently, in the API references, there are
@Input
and@Output
listed in such a way that seems to take for granted that the reader knows that if there exists an@Input
calledx
and an@Output
calledxChange
that you should be able to use the banana-in-a-box[(x)]
syntax to do a two way binding. I imagine this is a touchy subject because some will feel that this is obvious, and yet I've been using Angular 2 for a number of months and it was not at all clear to me, even though I've used that syntax with[(ngModel)]
plenty of times.On the API reference for tabs, it says selectedIndexChange was added to allow for two way binding. I'm sure some people will read that and think "that's abundantly clear", and indeed for some experienced Angular 2 developers, that probably does obviously imply that you can expect to use
[(selectedIndex)]
, but I think for other readers it's not so obvious.This library is advertised on the angular.io page, which makes me think the target audience is just as much novice Angular 2 developers as it is experienced ones. Since this is the case, I think API references should err on the side of being painfully explicit. It should not merely be said that 'two-way binding' is enabled, but explicitly that
[(thisSyntax)]
can be used.The text was updated successfully, but these errors were encountered: