Wanting to determine if a checkbox has been selected in the latest version of angular using an if statement.
My code:
<mat-menu #wj="matMenu">
<section><mat-checkbox (id)='1' (click)="$event.stopPropagation()">Cool Kids</mat-checkbox></section>
</mat-menu>
<div class="float-right">
<mat-action-row>
<button mat-button color="primary" (click) = "generateLink()" >Generate Link</button>
</mat-action-row>
AND IN component.ts:
generateLink() {
<HTMLInputElement>document.getElementById('1')
if(<HTMLInputElement>document.getElementById('1')){
console.log('y');
}
}
The idea is that once the submit button is pressed, the generateLink() method will evaluate to see all of the checkboxes checked by ID. If there is a better method to do this then please share. Essentially, there are 15 checkboxes, and I need to collect all of their values in an array at the end when a submit button is pressed.
angularjsis the incorrect tag for that framework.