Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get object data from select ng-options
Message
From
19/11/2015 04:31:23
 
General information
Forum:
Javascript
Category:
Other
Miscellaneous
Thread ID:
01627613
Message ID:
01627622
Views:
34
Likes (1)
>Update. Never mind, have an idea of how to solve it.
>
>Hi everybody,
>
>Part of my directive's template is the following:
>
>
><select class="col-md-3 form-control" ng-model="selectedItemId" id="item" name="item"
>                ng-disabled="!selectedCategoryId"
>               
>                ng-options="c.itemId as c.descrip for c in metaData.items | filter: {departmeId:selectedDepartmentId, categoryId:selectedCategoryId}">
>            <option value="">@String.Format(Labels.selectX, Labels.item)</option>
>        </select>
>
>Now, the metaData.items array also contains department, category, item columns. I want to somehow get them when I select the item from the list.
>
>What should I change here to be able to get to them? I would want to preserve ng-model = "selectedItemId" if possible and perhaps somehow get the info using ngChange event?
>
>Thanks in advance.

You could get the object from the selectedItemId. (using jQuery):
var item = $.grep(metadata.items, function(e){ return e.id === selectedItemId; })[0];
But why can you not have the item itself in ng-model ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform