I'm building an Ionic app and I have an issue reading the value of a ng-model.
HTML:
<select id="objetivos"
class="form-control col-xs-12 col-sm-12 col-lg-12"
ng-model="objetivosSelec"
ng-options="objetivo.value for objetivo in objetivos | filter: filtroServicio | orderBy: 'value' | unique: 'value'"
ng-change="">
<option value=""></option>
</select>
Controller:
.controller('TecnicasCtrl', function($scope, Tecnicas, Servicios,Objetivos,Indicaciones,Contraindicaciones) {
...
$scope.limpiarFiltro = function() {
alert($scope.objetivosSelec);
}
...
})
I just want to show on an alert the selected value of the select but nothing is displayed. If I add .val() then a JavaScript error is arised:
*Error: $scope.objetivosSelec is undefined*
I'm reading the Angular and Ionic doc and everything seems ok.
Has anyone an idea of what I'm doing wrong?