I have a collection of rooms in my $scope, with the structure:
$scope.model.rooms = [
{ RoomNumber: 1, Type: 'Single'},
{ RoomNumber: 3, Type: 'Single'},
{ RoomNumber: 5, Type: 'Double'},
{ RoomNumber: 6, Type: 'Single'},
{ RoomNumber: 12, Type: 'Double'}
];
I then create a 5x5 grid on my view as follows, and want to have the correct room type selected on the drop down, but I don't know how to do this binding properly.
<div data-ng-repeat="y in [1, 2, 3, 4, 5]" class="hotelRooms">
<div data-ng-repeat="x in [1, 2, 3, 4, 5]">
<h6>
Room #{{(y-1)*5+x}}
<select id="binType{{(y-1)*5+x}}" data-ng-model="model.rooms[/*WHAT DO I PUT HERE?*/].Type" data-ng-change="setRoomType((y-1)*5+x)">
<option value="Single">Single</option>
<option value="Double">Double</option>
</select>
</h6>
<div id="bin{{(y-1)*5+x}}" data-droppable="{{(y-1)*5+x}}" data-drop="addToRoom">
<div id="{{p.Id}}" data-draggable="" data-ng-repeat="p in model.participants | filter:{RoomNumber:(y-1)*5+x}">{{p.Name}}</div>
</div>
</div>
</div>
The array index isn't the same as the RoomNumber property.