>>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 ?
Yes, I've changed my mind and decided to use item itself as ng-model and get other properties using ng-change.
If it's not broken, fix it until it is.
My Blog