我有一个问题是,它可以声明纳克级的内部注释
纳克级={'测试':真,'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> 的jsfiddle例
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>
jsFiddle Example