2015-11-06 41 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;?我剛剛在屬性中使用了一個角度表達式的類似問題,它就像這樣工作。

相關問題