Click here to Skip to main content
14,690,541 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I thought that if I track the option by id then the model int and id int should align.

Here's what I mean:
I have an array of 'Options':
$scope.option = [
  {Id:0,Text:'Option0',Args:null},
  {Id:1,Text:'Option1',Args:null},
  {Id:2,Text:'Option2',Args:null},
];

The structure it that way because it is a basic type I use for populating option boxes

I also have an object that required an int representation of the option
$scope.object = {
 Title: 'this is a very trimmed down version of my object',
 Items:[{column:'text',select:0,description:'these are also fake.  represented in an ng-repeat table'}]


In the table i use this like so:
...
<tr data-ng-repeat="item in object.Items">
    <td>{{item.column}}</td>
    <td>{{options[item.select].Text }}</td>
    <td>{{item.description}}</td>
</tr>
...

which looks fine. When I click in a row, the 'EditPanel' is populated and shown.

(I actually have two issues at this point, but I'll stick with the simplest one in this QQ)
...
   <select data-ng-model="object.Items[selectedIndex].select" data-ng-options="option.Text for option in options track by option.Id"></select>
...

But the select options are always treated as an Option type.
I need to A: Display the currently selected option text and B: be able to change it.

Where am I going wrong?

What I have tried:

As described above. The option list always has the '?' first option:
<option value="?" selected="selected"></option>


and if I try to make a change then the select changes from 0 to { Id: 0,Text: 'Option0',Args: null }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900