AngularJS:有没有在绑定错别字调试模式? [英] AngularJS: is there a debug mode for typos in bindings?
问题描述
我刚刚浪费了一个小时的狩猎什么竟然一半是...
I've just wasted half an hour hunting for what turned out to be...
<select.... data-ng-options="x as x.name for x in customerController_clipped.options"
而不是
<select.... data-ng-options="x as x.name for x in customerController_Clipped.options"
即,一个字符的错字 - 在这种情况下,一个剪辑...代替剪辑...'
当然,这是很容易看到它时,它上面的孤立 - 但想想这里面巨大的HTML内容,而你现在知道我为什么问:
That is, a one-character typo - in this case, a 'clip...' instead 'Clip...' Sure, it's easy to see it when it's isolated above - but think of this inside huge HTML content, and you now know why I ask:
有没有办法问AngularJS中绑定的名称报告任何故障,以减轻我们的调试?这种失败的一个简单的控制台日志就足够了,而不是留下我们的组件的静音运行,空...
Is there a way to ask AngularJS to report any failures in names of bindings, to ease our debugging? A simple console logging of this kind of failure would suffice, instead of a silent operation that leaves our components empty...
推荐答案
我看不到建在做这样的东西,虽然也许你可以用angular.js筹集功能请求,或尝试写一拉请求投入 $ parseProvider
的选项?如果你想这样做,我可以看到,现在是通过改变在 $解析
服务,做任何的相互preting的code的唯一途径前pressions。
I can't see anything built in for doing this, though maybe you could raise with angular.js as a feature request, or try writing a pull request for putting an option in $parseProvider
? If you want to do this the only way I can see right now is by altering the code in the $parse
service which does the interpreting of any expressions.
我毫不犹豫地掏出快速测试,看看它是多么容易。原来的code是角1.1.5。搜索ANDYMOD在角1.1.5.js文件中看到的code我已经编辑。这基本上将的console.log
每当在是
和以Z
AXYZ前pression的部分是不确定的或为空,而不是忽略它。
I've plunked a quick test to see how easy it is. The original code is from angular 1.1.5. Search for ANDYMOD in the angular-1.1.5.js file to see the code I've edited. This basically adds a console.log
for whenever the y
and z
parts of a 'x.y.z' expression are undefined or null, rather than ignoring it.
这绝不是一个值得生产的解决方案,并且不工作,它要使用 NG-CSP
,但它表明的东西至少可以做到。也许你可以在子如果你需要再次测试的这几行...
This is in no way a production-worthy solution, and doesn't work it you want to use ng-csp
, but it shows something can be done at least. Maybe you can sub these few lines in if you ever need to test again...
这篇关于AngularJS:有没有在绑定错别字调试模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!