是否有可能宣布纳克级的内部意见 [英] Is it possible to declare comment inside of ng-class
本文介绍了是否有可能宣布纳克级的内部意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题是,它可以声明纳克级的内部注释
纳克级={'测试':真,'TEST1':真,//一些评论测试2:真正}
解决方案
它不会出现。你会需要使用多行注释语法像这样:
< DIV纳克级={'测试':真,'TEST1':真,/ *一些注释* /测试2:真正}>< / DIV>
但是,这将引发一个错误:
语法错误:令牌'*'是意外,希望[:]的前pression [{测试的29列:真的,测试1:真实的,/ *一些注释* /测试2 :真正}]开始[*一些注释* /测试2:真正}]
块引用>但是,您可以解决此通过在控制器/指令声明你的风格:
$ scope.styles = {
测试:真实,
测试1:真实,
/ *一些注释* /测试2:真实
};和包括在你看来:
< DIV NG-应用=MyApp的>
< DIV NG控制器=MyCtrl>
< DIV纳克级=风格>< / DIV>
< / DIV>
< / DIV>I have a question is it possible to declare comment inside of ng-class
ng-class="{'test':true,'test1':true, //some comment 'test2':true}"
解决方案It doesn't appear to. You would have needed to use the multiline comment syntax like so:
<div ng-class="{'test':true,'test1':true, /* some comment */ 'test2':true}"></div>
But that throws an error:
Syntax Error: Token '*' is unexpected, expecting [:] at column 29 of the expression [{'test':true,'test1':true, /* some comment */ 'test2':true}] starting at [* some comment */ 'test2':true}].
However you can work around this by declaring your styles in your controller/directive:
$scope.styles = { 'test': true, 'test1': true, /* some comment */ 'test2': true };
And including that in your view:
<div ng-app="MyApp"> <div ng-controller="MyCtrl"> <div ng-class="styles"></div> </div> </div>
这篇关于是否有可能宣布纳克级的内部意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文