让一个实例
{
"E-mail Address": "fultonlevy@ewaves.com",
"Related name": "",
"Home Address 2": "",
"Anniversary": "",
"First Name": "Rios",
"Business Address 2": "",
"Department": "",
"Display Name": "Baker Adkins",
"Home State": "",
"Business Country": "",
"Home Street": "",
"Birthday": "",
"Home Country": "",
"Pager": "",
"Categories": "",
"Home City": "",
"E-mail 3 Address": "bentleymccoy@cosmetex.com",
"Home Fax": "",
"Gender": "",
"Notes": "proident",
"Country Code": "",
"Job Title": "",
"Business Address": "",
"Web Page 2": "",
"Mobile Phone": "",
"Organization": "",
"Home Phone": "(962) 514-3534",
"E-mail 2 Address": "sheenaramirez@grupoli.com",
"Last Name": "Fisher",
"Nickname": "",
"Business Fax": "",
"Home Postal Code": "",
"Business Phone": "",
"Business Postal Code": "",
"Web Page": "",
"Business City": "",
"Business State": ""
}
<input ng-model="disName" type="text">
这是对象数组中的特定对象。
如何为假设[key = Display Name]
的键修改特定的值,并随着输入值的更改如何在对象中对其进行修改?
答案 0 :(得分:1)
在angularJS中,您将使用<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<div id="chartdiv"></div>
将object属性绑定到输入。
无需聆听任何更改,因为该框架会处理这些更改。
¿谁将这个对象提供给ng-model
?控制器,通过<input>
公开对象。
这是使用this
的有效示例。
https://plnkr.co/edit/lfD1LgML0nuRURKX4DCw?p=preview
如您所见,由于对象键上使用了空格,因此需要使用括号符号。
components
在一个真实的示例中,我想您的<input ng-model="$ctrl.obj['Display Name']">
将通过服务提供,如您在本示例中看到的那样:
https://plnkr.co/edit/fp1fBC59dJLettJBvD2p?p=preview
希望有帮助!