是否有可能宣布纳克级的内部意见有可能、纳克、意见

2023-09-14 23:09:53 作者:猪头三

我有一个问题是,它可以声明纳克级的内部注释

 纳克级={'测试':真,'TEST1':真,//一些评论测试2:真正} 

解决方案

它不会出现。你会需要使用多行注释语法像这样:

 < D​​IV纳克级={'测试':真,'TEST1':真,/ *一些注释* /测试2:真正}>< / DIV> 

但是,这将引发一个错误:

  

语法错误:令牌'*'是意外,希望[:]的前pression [{测试的29列:真的,测试1:真实的,/ *一些注释* /测试2 :真正}]开始[*一些注释* /测试2:真正}]

但是,您可以解决此通过在控制器/指令声明你的风格:

  $ scope.styles = {    测试:真实,    测试1:真实,    / *一些注释* /测试2:真实}; 
2021年中级会计3科内部考前60考点,只用10天,考前全就靠它了

和包括在你看来:

 < D​​IV NG-应用=MyApp的>    < D​​IV NG控制器=MyCtrl>        < D​​IV纳克级=风格>< / 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