Here’s what worked:
<select ng-init="team.captain=team.players[0]"
ng-model="team.captain"
ng-options="player.name for player in team.players"></select>
And what didn’t work:
ng-init="team.captain='0'"
ng-init="team.captain='John'"
My guess is that Angular goes beyond simple comparison of values or labels. It probably compares object references.
Related Contents:
- What are the nuances of scope prototypal / prototypical inheritance in AngularJS?
- Working with $scope.$emit and $scope.$on
- Passing data between controllers in Angular JS?
- ng-repeat finish event
- AngularJS : Why ng-bind is better than {{}} in angular?
- Two sets of parentheses after function call
- How do I share $scope data between states in angularjs ui-router?
- How to display length of filtered ng-repeat data
- $on and $broadcast in angular
- AngularJS with Django – Conflicting template tags
- AngularJs “controller as” syntax – clarification?
- How to set an iframe src attribute from a variable in AngularJS
- AngularJS : Difference between the $observe and $watch methods
- How to make ng-bind-html compile angularjs code
- How to define two angular apps / modules in one page?
- How to filter (key, value) with ng-repeat in AngularJs?
- AngularJS – Value attribute on an input text box is ignored when there is a ng-model used?
- firebase.database is not a function
- Injecting a mock into an AngularJS service
- AngularJS multiple filter with custom filter function
- Break promise chain and call a function based on the step in the chain where it is broken (rejected)
- use $http inside custom provider in app config, angular.js
- How to reduce javascript object to only contain properties from interface
- Does it make sense to use Require.js with Angular.js? [closed]
- $http.get(…).success is not a function
- Apply CSS style attribute dynamically in Angular JS
- angular ng-repeat in reverse
- ngRepeat Filter by deep property
- Reading Excel file using node.js
- Angular UI Router: decide child state template on the basis of parent resolved object
- How to implement history.back() in angular.js
- How to set default browser window size in Protractor/WebdriverJS
- Why do angularjs controller declaration have this syntax structure?
- Download text/csv content as files from server in Angular
- Angular.JS: views sharing same controller, model data resets when changing view
- Correct use for angular-translate in controllers
- Access index of the parent ng-repeat from child ng-repeat
- What is the difference between $routeProvider and $stateProvider?
- How to use parameters within the filter in AngularJS?
- Angular.js: set element height on page load
- Angularjs: understanding a recursive directive
- angular.js ng-repeat for creating grid
- deep merge objects with AngularJS
- Required attribute Not working with File input in Angular Js
- How to remove the hash # from the angularjs ng-route
- Best way to wait for .forEach() to complete
- Angular.js: Is .value() the proper way to set app wide constant and how to retrieve it in a controller
- angularjs force uppercase in textbox
- Angular.js ng-repeat filter by property having one of multiple values (OR of values)
- Directive is being rendered before promise is resolved