How do ng-options and ng-repeat differ?
In the following code, I have an ng-repeat that iterates through a list of people:
ng-options is the directive which is designed specifically to populate the items of a dropdown list. One major advantage using ng-options for the dropdown is, it allows us to pass the selected value to be an object. Whereas, using ng-repeat the selected value can only be string.
Id of the selected item is : {{selectedPerson}}
By Using the above method, the value of the selectedPerson is always a string.
Id of the selected item is : {{selectedPerson.id}}
Name of the selected item is : {{selectedPerson.name}}
Here, the value of the selected person is an object so we can print any required field of the object by passing the complete object.