Joined November 2013



@theatlasroom Now I understand. The reason why this is happening is because ng-repeat creates a new scope for every iteration. Therefore when the item is referenced, the data is lost upon refresh. Whereas referencing it directly from the list, which is stored in the controller's scope, will keep the data in sync. Even if you were to put campuses directly in scope, this wouldn't work. Like:

$scope.campuses = [];

This is all because of how $scope inheritance works. You can take a look at this:

Referencing item from ng-repeat in ng-model should still work.

<select class="form-control" ng-model="item">
    <option>Select a campus</option>
Posted to How to Become a Better Developer over 1 year ago

Very well written. You hit every nail on the head. Good job!

16 Karma
2,390 Total ProTip Views