In the directive I have 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>
The metaData.items array contains several columns (itemId - unique, descrip, departmeId, categoryId, department, category, item).
I want to somehow get these columns when I'm selecting an item. I would like to keep my ng-model to be the ItemId (e.g. selectedItemId) as I have right now.
What should I change to get to these columns (I can use ng-change event if needed)?
Are you looking to add more description in the drop down list?
Reference: http://odetocode.com/blogs/scott/archive/2013/06/19/using-ngoptions-in-angularjs.aspx
Edit: After reading again and wanting to use on-change() I assume you need this info in the directive / controller. In html:
In the controller:
I just need further clarification as to where you need to pull these variables.
If you need to show the others columns you need to change:
to:
Your
selectedItemId
model will contain an object when you select an option.Then you can use the
ng-change="showItem(selectedItemId)"
to show the others values. WhereselectedItemId
is the current object.Reference
Something like this: