Reputation: 357
let for an instance
{
"E-mail Address": "[email protected]",
"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": "[email protected]",
"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": "[email protected]",
"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">
this is a specific object in a array of objects.
How can I modify a specific value for a key for suppose [key = Display Name]
and with change in input value how can I modify it in object?
Upvotes: 0
Views: 31
Reputation: 841
In angularJS you'll bind the object property to the input using ng-model
.
There's no need to listen any change, because the framework takes care of that.
¿Who provides this object to the <input>
? The controller, exposing the object through this
.
Here's a working example using components
.
https://plnkr.co/edit/lfD1LgML0nuRURKX4DCw?p=preview
As you can see, you'll need to use bracket notation because of the use of spaces on your object keys...
<input ng-model="$ctrl.obj['Display Name']">
On a real world example, I suppose your data
will be provided using a service, as you can see in this example:
https://plnkr.co/edit/fp1fBC59dJLettJBvD2p?p=preview
Hope it helps!
Upvotes: 1