Is there a way to dynamically check or uncheck a checkbox in Angular 2? Specifically, I want the checkbox to be checked automatically when the value is 1 and unchecked when the value is 0.
public LightControl() {
this.dataLight = this._LightService.AutoLightController(this._ConnectService.SocketInstanse())
.subscribe(data => {
this.temp = JSON.stringify(data['status']);
})
}
HTML:
<div class="togglebutton">
<label> <input type="checkbox" [checked]="temp(change)="temp">Light</label>
</div>
- Currently, the checkbox is only checked when temp is true. It does not automatically uncheck when temp is false.