Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.

原创 2018年04月16日 10:52:58

我之前文章:https://blog.csdn.net/qq_36279445/article/details/78706784

当时没解决好。 全部禁用不太好,毕竟开发模式下完美点比较好


我遇到的问题是一个输入框,回车事件触发验证,检查输入内容与某个值是否相等,不相等的好久修改input样式

代码如下



ng应该是render了input之后,判断了里面的值并且已经完成了。但是呢, 我一按回车,校验之后修改了他刚render的地方。所以就给抛异常了。


这位老哥是表单中的,解决方法是:点击打开链接

老外的解释和可能的解决方法:点击打开链接,文章2:点击打开链接

ng的issue中说了,这是feature,不是bug。 GitHub上有这个 点击打开链接


我自己的解决方法

constructor( @Inject(DOCUMENT) private document: Document,
private cdr: ChangeDetectorRef,
...

在我回车进事件的时候,修改那个ngClass里面的值,就让ng停止检查

this.cdr.detach(); // 停止检测

this.cdr.reattach();


把[ngModel] 去除了,后台直接赋值的。 


版权声明:本文为Martin原创文章,未经Martin允许不得转载。 https://blog.csdn.net/qq_36279445/article/details/79957582

angular2:Expression has changed after it was checked

在angular2中,这个错误只会在dev开发模式下出现,在pro发布版本中不会出现,通过enableProdMode()可以控制 在组件中增加这段代码可以去掉这个检查,但是不建议这么做。impor...
  • erciyuan_nuonuo
  • erciyuan_nuonuo
  • 2016-12-19 22:18:23
  • 4476

Angular4_控制台错误

Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
  • qq_36279445
  • qq_36279445
  • 2017-12-04 10:05:03
  • 361

ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous v

在constructor中导入ChangeDetectorRef组件,通过手动控制检查机制的开始和结束 import { Component, ChangeDetectorRef } f...
  • fdsjiaoDoctor
  • fdsjiaoDoctor
  • 2018-01-29 10:24:26
  • 651

configure时出现错误:former value和current value不一样

./configure没有更新造成的 configure: error: `CC' has changed since the previous run: configure: former va...
  • f_066
  • f_066
  • 2014-12-21 09:38:02
  • 726

warning: push.default is unset; its implicit value has changed in Git 2.0 from 'matching' to 'simple

warning: push.default is unset; its implicit value has changed in Git 2.0 from 'matching' to 'simpl...
  • darongzi1314
  • darongzi1314
  • 2015-10-29 14:43:45
  • 1472

'root' has exceeded the 'max_questions' resource (current value: 100) (1226)

同事遇到一问题 mysqldump: Couldn't execute 'select @@collation_database': User 'root' has exceeded the 'max...
  • shshyeagle
  • shshyeagle
  • 2015-04-09 17:32:25
  • 2768

J-Flash ARM烧写Nor Flash时出错:PC of target system has unexpected value after programming

【已解决】J-Flash ARM烧写Nor Flash时出错:PC of target system has unexpected value after programming 【问题】 最近在...
  • hanxuefan
  • hanxuefan
  • 2012-04-16 22:34:41
  • 3063

warning: push.default is unset的解决方案

在执行 git push 时看到如下消息: warning: push.default is unset; its implicit value is changing in Git 2.0 from...
  • p_3er
  • p_3er
  • 2014-02-17 15:42:17
  • 11586

Git warning push.default is unset

warning: push.default is unset;  its implicit value is changing in Git 2.0 from 'matching' to 'simpl...
  • EXLsunshine
  • EXLsunshine
  • 2014-02-08 16:48:43
  • 13337

@RequestParam(value="condition",required=false)

错误描述 在完成搜索功能后前台和后台分别报如下的错 调试过程 刚开始一直以为是前台页面或者JS文件中参数名没有对应或者参数格式不对。 错误原因 后来发现是controller中的se...
  • u013919103
  • u013919103
  • 2016-08-22 23:11:38
  • 1295
收藏助手
不良信息举报
您举报文章:Expression has changed after it was checked. Previous value: 'true'. Current value: 'false'.
举报原因:
原因补充:

(最多只允许输入30个字)