Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Provide a way to define value property for ng-options #1833

Closed
caiotoon opened this issue Jan 18, 2013 · 5 comments
Closed

Provide a way to define value property for ng-options #1833

caiotoon opened this issue Jan 18, 2013 · 5 comments

Comments

@caiotoon
Copy link
Contributor

ng-options should provide a way to define which property of the object should be used as value for the option.

The expression select as label for value in array does provide a way to define which property will be associated to the ng-model, but it's not used as the value property of the options elements.

@latentflip
Copy link
Contributor

@caiotoon: can you clarify this a bit? Do you mean that in an example like this: http://jsfiddle.net/SHwb5/1/ The options that are generated don't have value="red", but have value="0"? And you would like to be able to provide an option for what field on the object should be used for value="<here>"?

If so, what's the use case? Presumably the whole point in using ng-options, rather than an internal ng-repeat is simplicity rather than power, and it doesn't matter what value="<>" gets set to, as the directive deals with it internally, ensuring the correct actual update is set on the model.

@caiotoon
Copy link
Contributor Author

caiotoon commented Feb 6, 2013

I'm thinking more of non-angular plugins that rely on the select field value. I do agree that it's simpler to not care with it, but if I need to, there is currently no way to achieve it.

Of course we could change the plugin and use angular.element().scope() to get the info. But seems to me that it's "natural" to count on the field's value on certain situations, like using a plugin, submitting the form or integrating with other pieces of non-angular code.

What you think?

@perymimon
Copy link

the issue is like that. for "action.id as action.name for (index,action) in actions"
when actions :[
{id: 1, name: "openCashier"},
{id: 2 ,name: "openCashierOffer" }
{id: 3, name: "openInviteFriends" }
]
the result is :
openCashier openCashierOffer openInviteFriends

and this BUG because the label we write is action.id so the result should be :

openCashier openCashierOffer openInviteFriends

@caiotoon
Copy link
Contributor Author

caiotoon commented Feb 7, 2013

Sorry @perymimon, I'm not sure if I understood your point. But I don't believe we're talking about the same thing, as I'm not talking about a bug, but a feature request.

@caiotoon
Copy link
Contributor Author

Closed by #2040.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants