Trying to update array object value but not working. I am trying to update item value from an array But not updating. How to resolve this issue.
ngOnInit() { this.arr = [ { lable: 'test1', item: 'Row6', }, { lable: 'test2', item: 'Row9', }, { lable: 'test3', item: 'Row4', }, ]; } updateVal() { this.arr = this.arr[0].item = 'Row9'; console.log(this.arr); }
Demo: https://stackblitz.com/edit/angular-ivy-srsirm?file=src%2Fapp%2Farrcom%2Farrcom.component.ts
this
works. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…this.arr[0].item = 'Row9';
this.arr[0].item = 'Row9';
withoutthis.arr = this.arr[0].item = 'Row9';
?