简体   繁体   中英

Angular 2 Material: “Expression was changed [..]” with mdInput

<md-input-container>
   <input mdInput type="number" min="0" [(ngModel)]="troup.amount" *ngIf="wave.Mode === SimulationModes.Normal">
</md-input-container>

I've recently updated from the previous version of material angular to the newest one, and needed to change all my inputs to match the new criteria with <md-input-container> instead of <md-input> .

When compiling, I get a Zone Error telling that the value changed from "undefined" to ''.

In order to make it work, you no longer should put any *ngIf in the mdInput directive, but this should be placed on the container instead:

<md-input-container *ngIf="wave.Mode === SimulationModes.Normal">
   <input mdInput type="number" min="0" [(ngModel)]="troup.amount">
</md-input-container>

This solves the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM