Re: [angular.js] ng-options value and label

2,940 views
Skip to first unread message

Pawel Kozlowski

unread,
Jul 6, 2012, 4:09:56 PM7/6/12
to ang...@googlegroups.com
Hi!

I was surprised myself but actually it is possible, have a look at his
jsFiddle: http://jsfiddle.net/pkozlowski_opensource/UakS3/2/
It looks like expressions you can use in the ng-options are quite
powerful. Angular is simply amazing!

Hope this helps,
Pawel

On Fri, Jul 6, 2012 at 4:20 PM, Teren Teh <ter...@gmail.com> wrote:
> Hi there,
>
> Is there anyway to customize the value and display of the options created by
> ng-options other than what's listed here:
> http://docs.angularjs.org/api/ng.directive:select
>
> For example, if my ng-options are from an array of [{ type:'cat',
> name:'Tabby'}, {type:'cat', name: 'Bobby'}, {type:'dog', name:'Rover'}]
>
> How would I do this?:
>
> <option value="Tabby">Tabby (Cat)</option>
> <option value="Bobby">Bobby (Cat)</option>
> <option value="Rover">Rover (Dog)</option>
>
> From the docs, it looks like you have no control over the values and the
> display name is based on one attribute of the object.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/angular/-/SnTyjtCqrv8J.
> To post to this group, send email to ang...@googlegroups.com.
> To unsubscribe from this group, send email to
> angular+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/angular?hl=en.

poppin...@gmail.com

unread,
Oct 2, 2012, 3:35:47 PM10/2/12
to ang...@googlegroups.com
Almost amazing - the value for each option is still integral.

Second issue: What if you want to set which option is selected?

On Thursday, July 19, 2012 8:38:17 AM UTC-7, Teren Teh wrote:
Hi Pawel,

Totally agreed that Angular is simply amazing. Yes, this is exactly what I'm looking and am definitely surprised. I wonder how much "code" can we put in as expressions.

Thanks,
Teren
Message has been deleted

hhs...@gmail.com

unread,
Oct 2, 2012, 5:26:25 PM10/2/12
to ang...@googlegroups.com, poppin...@gmail.com

yas...@gmail.com

unread,
Oct 9, 2012, 7:26:33 AM10/9/12
to ang...@googlegroups.com
Thanks a lot. Very informative.  :)
Reply all
Reply to author
Forward
0 new messages