How To Set The Value Property In AngularJS' ng-options

For More Videos Visit Our YouTube Channel




Here we explain how to Set The Value Property for ng-options. In latest version of AngularJS, this can be achieved by using track by expression. We can set the actual value for the value attribute of select element. Lets consider one example here.

How To Set The Value Property In AngularJS' ng options, Set The Value Property In AngularJS' ng options, track by in AngularJS ng options, how to use ng-option to set default value, angularjs - Can't set selected value of ng-options, How to set the initial selected value of a select element using AngularJS' ng options, HTML,PHP,Asp.Net

How To Set The Value Property In AngularJS' ng options, Set The Value Property In AngularJS' ng options, track by in AngularJS ng options, how to use ng-option to set default value, angularjs - Can't set selected value of ng-options, How to set the initial selected value of a select element using AngularJS' ng options, HTML,PHP,Asp.Net

In the above example, the collection is ArrayData with two properties. DisplayID and DisplayText. ArrayData is bind to the scope object ScopeObject.

Initially selected value is set to DisplayID = 2 by using SelectedData. On the View side we use ng-option within select for showing the final result.

ng-options = " data.DisplayText for data in ScopeObject.ArrayData
track by data.DisplayID "



Here we have used the track by data.DisplayID. By this way we can Set The Value Property for ng-options.