This code is not working and I can't tell why.
HTML
<select id="provincia" class="form-control" ng-model="ciudades" ng-options="provincia for (provincia, ciudades) in provincias">
<option ng-model="valor_ciudad" value=''>Elegir</option>
</select>
JS
$scope.$watch('ciudades', function(newval, oldval){
debugger;
if (newval){
$scope.prov = newval;
}
});
What do I want to do? I am trying to get the value picked by user because the variable ciudades has an array of values.
$scope.provincias = {Florida:['Miami', 'Orlando']}
If the user picks Florida, then $scope.ciudades will be ['Miami', 'Orlando']. What I need to know is if the user choose Florida or another city. (.watch didn't work, not even stopping on debugger)
Did I make myself clear?
ng-changefor that Read this (Scope $watch Performance Considerations)