I've been struggling for several days now with ngOptions and ngRepeat. I am trying to create a select option for a people control. The REST service is returning an array as shown below. Despite trying various solutions from Stack Overflow and the Angular documentation, I am unable to display even a single attribute. What am I doing wrong?
Below are some of my attempts.
Thank you in advance for any advice and assistance.
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.name = 'Superhero';
$scope.players = [{"id": "1", "nickName" : "Cole", "firstName" : "Mark", "lastName" : "Coleman"}, {"id" : "2", "nickName" : "West", "firstName" : "Peter", "lastName" : "West"}];
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<form>
<label>Captain:
<select ng-model="team.captain">
<option ng-repeat="player in players" value="{{player.id}}"> {{player.firstName}} {{player.lastName}}</option>
</select>
</label><br />
</form>