I have received a json response containing various fields, including the rewards.rewardName value. I'm trying to figure out how to bind this specific value to [(ngModel)] in Angular 2.
[
{
"id": 18,
"gname": "learning ramayanam",
"goalCategory": "Education",
"goalSubCategory": "short-term",
"goalDesc": "good",
"rowStatusCode": "D",
"createID": "1",
"createTS": null,
"updateID": "Ram",
"updateTS": null,
"rewards": {
"rewardID": 1,
"rewardName": "Laptop"
}
]
This is my current code. I need help with binding the value in ngModel.
ngOnInit() {
this.route.params
.forEach(params => {
this.isEdition = !!params['id'];
if (this.isEdition) {
// this.getDocument(params['id']);
this.itemPromise = this.http.get('http://localhost:8080/dy/get-goal?id='
+
params['id'])
.map(res => res.json()).toPromise();
this.itemPromise.then((item: any) => {
console.log(item);
var arr = JSON.parse(item);
this.item = arr[0];
return item;
});