-
Notifications
You must be signed in to change notification settings - Fork 27.5k
radio buttons are not initialized to the model #271
Comments
So the problem is ultimately that value is dynamically bound ( That's as far as I've diagnosed this so far. It ended up sending me quite deep down the rabbit hole of Angular, for one of my relatively early ventures. I'm seeing |
This is the best I've managed to come up with. It makes my linked test case work, but it makes a lot of tests fail. I don't yet understand enough about Angular's internals to do better. |
You can't bind to value. This is not how angular was designed. here the value is default. If you want to change the value of the input you but rather this -- Misko On Mon, Mar 28, 2011 at 12:07 PM, arantius <
|
We don't want to change the value. We want to build the template, from data. We request as a $resource some data, and we build a form off of said data. So we have, basically/paraphrased:
There is no way for us to write a hard-coded bit of HTML that contains radio buttons with the right value attributes, they exist only as data. They're different. For our use case, this value (choices) never changes at run time, but it can be different each time we load the page. Is there some other way to get data into attributes besides binding? |
Are you running into this: #316? On Mon, Mar 28, 2011 at 3:09 PM, arantius <
|
That appears to be the effectively the same issue, yes. I don't see any description of what the expected result is, but the result I see is that no radio button is checked after loading (nor after clicking the 'load' link), and it seems the "that" choice should be. But if I change the selection then click 'load', the selection is properly updated. |
Correct. We are doing some major refactoring, and are hoping that these On Tue, Mar 29, 2011 at 7:39 AM, arantius <
|
I got the same problem which radio button looked unchecked and then I fixed it like this;
The thing is name="form-field-for-{{field.fields_id}}" should not be duplicated in same file. |
I had a problem where radio buttons rendered by angular were not being checked by default even if their value attribute and binding seemed equal. I learned in this StackOverflow answer to use ng-value instead, and it works now. http://stackoverflow.com/questions/18518251/angularjs-radio-button-checked#comment27231547_18518425 |
I found this post from September which seems to imply the issue is fixed:
http://groups.google.com/group/angular/browse_thread/thread/520cde44a3ac15c
But I still see problems. The radio buttons all start empty (unchecked). Checking any of them puts the value in the model, but the model having a value does not check the buttons.
Test case: https://gist.github.com/818607
Displays the model, on load, as
{
"choices":["alpha","beta","gamma"],
"value":"gamma"}
But the gamma radio button is not checked. Checking any updates the 'value' property.
The text was updated successfully, but these errors were encountered: