Vote count:
0
I am trying to create a Select tag using AngularJS. I am using the ngOptions and ngModel for databinding.
Now: If let's say I have a data source like follows:
$scope.doesNotBind = [
{ID: 12, Title: "12 - Does not bind"},
{ID: 14, Title: "14 - Does not bind"},
];
$scope.doesNotBindModel = {ID: 14, Title: "14 - Does not bind"};
<select ng-options="value as value.Title for value in doesNotBind" ng-model="doesNotBindModel">
<option value> </option>
</select>
That will never bind. But if I bind the model like this; it works!
$scope.doesNotBindModel = $scope.doesNotBind[1];
Am I using the syntax incorrectly or is this expected behaviour?
I have created a POC to demonstrate fully what I am saying.
Interestingly enough, when there is no as syntax (no object data binding), it works perfectly (in demo as well)
Thanks!
asked 1 min ago
AngularJS select not binding when using value as value syntax
Aucun commentaire:
Enregistrer un commentaire