Expression has changed after it was checked. PrevIoUs value: 'true'. Current value: 'false'.
在Component中连续多次修改一个属性值,F12页面有报这个错,找到几个解释。
Angular utilizes zones to know when an event is fully processed by patching some async APIs like (addEventHandler,setTimeout,...) and then runs change detection after each event.
In dev mode Angular does an additional change detection run,just after the first one. Because there was no event in between,no change should have happened.
If the model still changed,Angular considers this to be a possible bug.
That's exactly it. In development mode the change detection runs a second time and compares the current value with the first run.
If the value differs,then it "thinks" that the change was caused by itself. That's why it throws. However this doesn't happen in production mode with .
解决方案:
http://www.jianshu.com/p/a5402332315d
來源:简书enableProdMode()import { Component,enableProdMode } from '@angular/core'; enableProdMode();
这段代码需要写在,别忘了引用 enableProdMode