[英]Angular material select get reset
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"></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>
</md-select>
</md-input-container>
</div>
<div ng-controller="EntidadBancariaController">
<md-input-container class="md-icon md-block">
<label>Entidad bancaria</label>
<md-icon class="material-icons"></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>
</md-select>
</md-input-container>
</div>
</form>
As I post in a comment: 当我发表评论时:
You are binding both selects to the same ng-model="_tarjeta.medioPago"
, so this is the expected behaviour. 您将两个选择都绑定到相同的
ng-model="_tarjeta.medioPago"
,因此这是预期的行为。
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. 将第二个选择的
ng-model
更改为控制器的另一个变量,问题应该消失。
Hope it helps 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.