gpt4 book ai didi

javascript - Angular Js 绑定(bind)带有带有静态索引的 JSON 数组的文本框

转载 作者:行者123 更新时间:2023-11-30 11:47:02 26 4
gpt4 key购买 nike

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

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

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

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

最佳答案

在 Controller 中你分配给一个变量并绑定(bind)它,

Controller

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

HTML

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

关于javascript - Angular Js 绑定(bind)带有带有静态索引的 JSON 数组的文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40651485/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com