Reputation: 165
I currently have two separate arrays that I am trying to use to create a Select in Angular.js
My layout is like this: One array has all of my information for the table as well as a foreign key ID that links to the second table.
The second array has a key and a string value name.
What I am wanting to do is use the select in my html table so the user can select the ID that will be used in the first array by viewing the names listed in the second array.
Here is what my current code looks like (with i coming from the ng-repeat and ItemType being the second array)
<select ng-model="i.ItemTypeID"
ng-options="t.Name as t.Name for t in ItemType"
ng-selected="{{i.ItemTypeID == t.ItemTypeID}}">
</select>
EDIT: To further clarify, I am using a pagination in place of ng-repeat for my project, but to my knowledge they act similarly. Here is the code for that:
<tr dir-paginate-start="i in Item|orderBy:sortKey:reverse|filter:scannedValue|itemsPerPage:5" id="display">
Upvotes: 1
Views: 186
Reputation: 165
I figured out my issue. I was trying to use the Name in the ng-options instead of the ID. By changing the code to the following I was able to make it work for me:
<select ng-model="i.ItemTypeID"
ng-options="t.ItemTypeID as t.Name for t in ItemType"
</select>
Upvotes: 1