I am developing a solution with web api net core, angular 16, typescript, Material UIO and I need to check a checkbox depending of a value, that is, if the value is true, I check the checkbox, if not, I uncheck it.
I tried it with javascript using:
document.getElementById("remember").checked=true or false depending on the case but it sends me an error.
The code that does not send me an error but does not check the checkbox, in typescript is:
this.formLogin.controls["remember"].setValue(true);
or false depending on the case.
The HTML code of the mat-checkbox is:
<div class="row" style="margin-top: 0px !important; padding-top: 0px;">
<mat-checkbox id="remember" value="checked"
style="text-align: left !important; vertical-align: top !important; margin-top: 0px !important; padding-left: 32px; padding-top : 0px !important;"
(change)="onChangeStatus($event)">Remember Me</mat-checkbox>
</div>
I have searched for solutions on Google and have not found any, that is why I turn to you for help
If anyone has already encountered this case and wants to share the solution. Thanks in advance.