2015-11-06 43 views
0

您能否建议如何将{{$count}} times per month <span ng-include="'views/partials/month-dates.html'"></span>指定为translate-plural属性?我可以在角度指令的属性值中使用双引号吗?

E.g.以下表达式会导致解析错误:

<translate translate-n="notification.Data[flightType][direction].Days.length" translate-plural="{{$count}} times per month <span ng-include=\"'views/partials/month-dates.html'\"></span>"> 
    N times per month on <span ng-include="'views/partials/month-dates.html'"></span> 
</translate> 
+0

每月尝试'translate-plural =“{{$ count}}次

+0

我修复了我的问题,通过ng-include指令中的变量: \t

\t “> \t牛每一个月倍<跨度NG-包括=” monthDatesView“> \t

+0

然而问题仍然是开放的:它是可能在角度指令中使用双引号? –

回答

0

因为我没有收到任何好的答案,所以我会分享我在该主题中找到的内容。

  • 似乎没有办法在Angular 视图中使用双引号。
  • 如果确实需要使用指令属性中双引号 有2种方式:

    1. 如果有可能(在我的情况下,它是不是)用单引号来包装 的属性值和在属性值或副 双引号反之亦然
    2. 您也可以在 属性值与变量像我一样
代替恒定加上双引号

见下文

<div ng-init="monthDatesView = 'views/partials/month-dates.html'"></div> 
<translate translate-n="notification.Data[flightType][direction].Days.length" translate-plural="{{$count}} times per month on <span ng-include='monthDatesView'></span>"> 
    N times per month on <span ng-include="monthDatesView"></span> 
</translate> 
1

解决方案你有没有尝试使用&quot;&#34;?我刚刚在属性中使用了一个角度表达式的类似问题,它就像这样工作。

相关问题