2015-10-05 51 views
0
products = [{"id":null,"classId":1,"multiplier":2,"name":"Deve","units":2},{"id":null,"classId":1,"multiplier":2,"name":"Site","units":2}] 

我從ajax調用了此JSON對象(產品)。我使用ng-repeat並希望將值(單位和乘數的乘積)賦值給value屬性。我在我的模板中這樣做,但值不分配。當我在瀏覽器中檢查值時,我只看到這個字符串({{(p.units)*(p.multiplier)}})被分配給值。在angularjs模板中ng-model的值的乘積

<tr ng-repeat="p in products> 
<td> 
<div value="{{(p.unit) * (p.multiplier)}}" fs-counter data-min="0" data-max="10" data-step="{{p.multiplier}}" data-width="75px" data-change="productUnitsChanged(p)"> 
</td> 
</tr> 

任何人都可以建議我正確的解決方案,以指定價值產品(例如:4)價值?我使用的角度計數器指令 - https://github.com/Firestitch/angular-counter

感謝

+1

您的意思是使用NG-綁定? – Wawy

+0

對不起我更新了我的帖子,我正在使用fs-angular counter指令並嘗試分配其值屬性 - github.com/Firestitch/angular-counter – Adds

回答

0

的firestitch指令的值屬性不能是表達式,這意味着它不能什麼東西在雙大括號。它必須是一個變量。像這樣將工作:

<div value="p.multiplier" fs-counter data-min="0" data-max="10" data-step="1" data-width="75px""> 

,但這樣的事情是行不通的:

<div value="{{p.multiplier}}" fs-counter data-min="0" data-max="10" data-step="1"