带有静态索引的JSON数组的Angular Js绑定文本框

时间:2016-11-17 09:46:04

标签: javascript angularjs json

我有5个固定的Textbox,我有一个JSON数组,它应该与Textbox绑定。第0个索引元素将与第1个文本框绑定。

<input type="text" class="form-control col-md-5" ng-model="jsonArray[0].amount">

我需要在 ng-model 中添加什么?

jsonArray中的

有5个Json对象,但文本框中不会显示任何内容。

1 个答案:

答案 0 :(得分:3)

在控制器中,您可以为变量分配并绑定它,

<强>控制器

$scope.amount = jsonArray[0].amount;

<强> HTML

<input type="text" class="form-control col-md-5" ng-model="amount">