我有一個像var names=["price","quality","service"]
這樣的數組,我必須將該數組轉換爲對象,如names=[{"name":"price", "value":"1.3"},{"name":"quality","value":"3"},{"name":"service","value":"3.4"}]
。每次數組值都不相同。我需要使用ng-repeat
像將數組轉換爲對象Angularjs
<div ng-repeat="n in names">
<input name="rating" ng-model="n" value="0"/>
</div>
做構建輸入字段與價值如何,我可以爲對象當用戶提交表單取回值。誰能幫我。
更新
我需要JSON作爲這樣:::
names=[{"name":"price", "value":"1.3"},{"name":"quality","value":"3"},{"name":"service","value":"3.4"}]
ThanQ!
哪裏的值來自何處? – 2014-10-28 10:14:05
值來自數據庫 – chandu 2014-10-28 10:30:56