I am trying to expand and collapse each table row without adding new properties(expanded1 and expanded2) in the json data. How to do it. Is it possible or not?
app.component.ts:
export class AppComponent implements OnInit{
expanded1 = false;
expanded2 = false;
data1 = [
{
name: 'john',
place: 'forest',
phone: '124-896-8963'
},
{
name: 'Jay',
place: 'City',
phone: '124-896-1234'
},
{
name: 'Joseph',
place: 'sky',
phone: '124-896-9632'
},
];
ngOnInit(){
// this.fooGet();
}
// fooGet() {
// const modifiedData = this.data1.map((d) =>
// Object.assign(d, { expanded1: false, expanded2: false })
// );
// console.log(modifiedData);
// }
}
Demo: https://stackblitz.com/edit/angular-jfslbe?file=src%2Fapp%2Fapp.component.ts