I have the following case when using ng-options
in my dropdownlist.
This is my html:
<div class="col col50 colmin">
<div class="pull">
<div>{{selectIdCuenta.nombreAlias}}</div>
<select name="ifield06" ng-model="selectIdCuenta" ng-change="getListRecibos()" ng-options="cuentas.nombreAlias for cuentas in listCuentasCoorporativas">
<option value="">Cuenta</option>
</select>
</div>
</div>
</div>
and this is my controller that fills the select:
productoServicio.getCuentasCoorporativos().then(function(response) {
$scope.listCuentasCoorporativas = response.data.obtenerListadoMovilCorporativoCuentaResponse.listadoCuenta;
angular.forEach($scope.listCuentasCoorporativas, function(val, key) {
if (val.idCuenta == idCuentaCoor) {
$scope.selectIdCuenta = $scope.listCuentasCoorporativas[key];
}
});
}, function(error) {
$scope.status = 'El cliente no cuenta con Lineas Moviles Coorporativas: ' + error.message;
});
which works well when rendering and the $scope.selectIdCuenta
is selected correctly but when you give it in the value "Cuenta"
the dropdown shows empty and does not load the value "Cuenta"
.
I'm checking that it does not do anything if you select that value but I need to show the default value "Cuenta"
of the HTML.
Please any help or guide Greetings
Additionally the array that I get (Json) is as follows:
{
"listadoCuenta": [{
"idCuenta": "1000.123.67",
"nombreCuenta": "Principal",
"aliasCuenta": "Padre",
"nombreAlias": "Padre"
}, {
"idCuenta": "1000.543.1",
"nombreCuenta": "Principal",
"aliasCuenta": "Padre",
"nombreAlias": "Cta Nueva"
}, {
"idCuenta": "5.4300.12",
"nombreCuenta": "Principal",
"aliasCuenta": "Padre",
"nombreAlias": "Cta Otros"
}]
}