Objects and ngFor bind (or change a toggle inside a ngFor)

I m developing a simple app. I make a request obtaining a object like this;

[{“name”:“device-1”, “code”:“00001”, “status”: true},
{“name”:“device-1”, “code”:“00001”, “status”: true},
{“name”:“device-1”, “code”:“00001”, “status”: true}]

the i use a ngFor to display each as a toggle.

I can read the toggle value inside my page controller, but i cant change the value from the controler (for example to update the device status)

what’s de correct approach?


Insufficient information: please post all code needed to replicate the problem.


depending to your needs you can use property binding to manipulate from .ts side. see here https://coursetro.com/posts/code/58/Angular-4-Property-Binding-Tutorial

Or if you need to fetch the whole component then you can use @Viewchild or @Viewchildren. see here https://blog.angular-university.io/angular-viewchild/

Best regards, anna-liebt

Thanks anna,
It’s working with property binding.