Why Does My Select Ng-model Not Reflect My Selected Ng-option?
I'm trying to get this code to provide a value in my select ng-options:
Solution 2:
The answer of @charlietfl was spot on. ng-if
created a child scope so you won't be able to access your selectedMovieId
like that.
If for some reason you need to use primitive types for binding, you can change your binding as following (this is just a workaround)
<selectng-model="$parent.selectedMovieId"ng-if="movies.length>0"ng-options="movie.id as movie.title for movie in movies track by movie.id"></select>
It will work because it's using the implicit $parent
attribute of the current $scope
.
Read more:
Post a Comment for "Why Does My Select Ng-model Not Reflect My Selected Ng-option?"