Works great - thanks a million!
I still wonder what to make of the description of "track by" in the "select
ng-options" docs:
http://code.angularjs.org/1.2.9/docs/api/ng.directive:select
"Used when working with an array of objects. The result of this expression
will be used to identify the objects in the array."
On Tuesday, January 21, 2014 3:58:57 PM UTC+1, Stephen Friedrich wrote:
>
> I cannot get ng-options to work:
>
> My model that I'd like to update via a drop down is
> wifiSettings = { channelNumber: 2, ... }
>
> and the available options should come from an array like
> availableChannels = [
> {
> number: 1,
> frequency: 2412,
> maxTransmitPower: 20
> },
> {
> number: 2,
> frequency: 2417,
> maxTransmitPower: 20
> },
> ....
> ]
>
> I tried with several expressions in ng-options, but nothing seemed to
> work, for example, this does never show the selected value:
> <select id="channel"
> ng-model="wifiSettings.channelNumber"
> ng-options="channel.number as channel.number for channel
> in availableChannels track by channel.number">
> </select>
>
> (Ideally the labels in the options should be an expression like "{{
> channel.number + '(' + channel.frequency + 'MHz)' }}" but that's another
> story.)
>
> Here is a (broken) example: http://plnkr.co/edit/4e28Pe?p=info
>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.