ngOptions "track by" expression ngOptions "track by" expression javascript javascript

ngOptions "track by" expression


track by just helps Angular internally with array sorting as far as I know. The value of the options is defined by the first argument (in your case item). If you want it to be by id then you should use item.id as item.name for item in items


"track by" is usefull when in ng-options array of objects and model you use object also. but you do not want track options by the reference of the object in model. Using "track by" you point that you track options by desired field of model.

in your case with "track by" $scope.serverDTO must be like {id:1,name:"test"}