Paulo Galdo Sandoval Paulo Galdo Sandoval - 11 months ago 70
Javascript Question

Angular material select get reseted

i'm facing another problem with Angular Material.

Now i have a form, with two select. The problem is when i select one value in any of this two select, the other one get reseted and loose his value.

is this a bug?? or maybe i'm doing something wrong?

<form name="addTarjeta">
<div ng-controller="MedioPagoController">
<md-input-container class="md-icon md-block">
<label>Tipo de tarjeta</label>
<md-icon class="material-icons">&#xE252;</md-icon>
<md-select ng-model="_tarjeta.medioPago" md-on-open="listaMedioPago()"
required name="medio">
<md-option value="{{medio}}"
ng-repeat="medio in medioPagos track by medio.idMedioPago">{{medio.nombrePago}}</md-option>
<div ng-controller="EntidadBancariaController">
<md-input-container class="md-icon md-block">
<label>Entidad bancaria</label>
<md-icon class="material-icons">&#xE84F;</md-icon>
<md-select ng-model="_tarjeta.medioPago" md-on-open="listaEntidadBancaria()"
required name="entidad">
<md-option value="{{entidad}}"
ng-repeat="entidad in entidadBancarias">{{entidad.nombreEntidad}}</md-option>

i'll try to make soon as posible a fiddle to show this. Please any idea?


As I post in a comment:

You are binding both selects to the same ng-model="_tarjeta.medioPago", so this is the expected behaviour.

I think it's probably just a typo in your code. Could you check it? Change the ng-model of (probably) your second select to another variable of the controller and the problem should disapear.

Hope it helps