javascript ng-change 抛出错误 [$compile:ctreq]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22403507/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ng-change is throwing error [$compile:ctreq]
提问by mulla.azzi
I am using angularjs 1.2.14, the code is working fine without ng-change. As soon as i add the code for ng-change in checkbox. it throws the error.
我正在使用 angularjs 1.2.14,代码在没有 ng-change 的情况下工作正常。一旦我在复选框中添加了 ng-change 的代码。它抛出错误。
Error: [$compile:ctreq] http://errors.angularjs.org/1.2.14/$compile/ctreq?p0=ngModel&p1=ngChange
at Error (native).....
Can anyone please help? Thanks in advance.
有人可以帮忙吗?提前致谢。
回答by mulla.azzi
to use ng-change
in your element you should also specify ng-model
which i had missed. Thanks for your time.
要ng-change
在您的元素中使用,您还应该指定ng-model
我错过了哪些。谢谢你的时间。
回答by Eugene P.
http://plnkr.co/edit/oF8o6kU7zBDaJg4ts6TU?p=preview
http://plnkr.co/edit/oF8o6kU7zBDaJg4ts6TU?p=preview
See working sample.
请参阅工作示例。
ng-change requires ng-model, without it will not work
ng-change 需要 ng-model,没有它就行不通