My ngModel myOpt2 does not change when selected, myOpt if it works. Any reason why it does not change?
Mi ngModel myOpt2 no cambia al ser seleccionado, myOpt si functiona. Alguna razon por la que no cambia?
var app = angular.module('App_Alta', []);
app.controller('Ctrl_Categorias', function ($scope, $http) {
$scope.lstCatalogos = [{ sNombre: "Vehículos", iID: 1, iIdPadre: 0, bUltimo: false }]
$scope.lstSubCategorias = []
$scope.$watch("myOpt", function (newval, oldval) {
if (newval == undefined || newval.iID == 0) {
return false;
}
$scope.lstSubCategorias[0] = [{ sNombre: "Autos", iID: 17, iIdPadre: 1, bUltimo: true }]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="example-wrap" ng-app="App_Alta" ng-controller="Ctrl_Categorias" id="AppAngular1">
<div>
<header Class="example-title">
Seleccione una categoria
</header>
<div class="example">
<select class="form-control"
ng-model="myOpt"
selectpicker="{ noneSelectedText: 'Seleccione una opción' }"
select-model="lstCatalogos"
ng-options="x.sNombre for x in lstCatalogos"></select>
</div>
<div class="example" ng-repeat="l in lstSubCategorias">
<select class="form-control"
ng-model="myOpt2"
selectpicker="{ noneSelectedText: 'Seleccione una opción' }"
select-model="lstSubCategorias"
ng-options="x.sNombre for x in l"></select>
</div>
</div>
<p>{{myOpt}}</p>
<p>{{myOpt2}}</p>
</div>
no cambia?