Accessing an object from ng-option

A lot of questions have bees asked about accessing objects but I couldn't find one that answers my problem.

I have a dynamically created object like this :

    id: "ISO 19115:MD_Metadata:identificationInfo:extent:temporalElement:extent",
    value: "ISO   19115:MD_Metadata:identificationInfo:extent:temporalElement:extent:endPosition",
    begin: "ISO 19115:MD_Metadata:identificationInfo:extent:temporalElement:extent",

What I'd like to do is display in ng-options (angularJS) the couples (id - ISO 19115:MD... , value - ISO 19115:MD...) for the second parameter is the path through the first.

So I was wondering if something like that could work:

 <select ng-model='selectedtype' ng-options="(item[0] + item[1]) for item in types">
        <option value="">select type</option> 

note that my object is in $scope.types.

This does not work so is there a solution like a designated keyword for accessing name:value couple.

I'm aware that this is quite bad designing for an object and that I should try something like this :

        'name': 'id',
        'value':'ISO 19115 ...',

But I'd appreciate another solution if possible.


You can use the following format in order to access an objects key-value pair:

ng-options="key as key+': '+value for (key, value) in types"

See, also, this short demo.

ng-options supports string concatenations. So you can easily use something like,

ng-options="'id-'', value-'+item.value for item in types"


Need Your Help

How to access URL helper from rails module

ruby-on-rails ruby url model helper

I have a module with a function. It resides in /lib/contact.rb:

How to decode ogg vorbis file java?

java lwjgl ogg vorbis

I'm getting started with lwjgl and openal, so I want to be able to decode an ogg vorbis file and play it with openal. My question is: how can I decode an ogg file from java, get the frequency, pcm ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.