Reputation: 29
I am unable to create a Chrome alert dialog when clicking on a button.
<button mat-raised-button matStepperNext color="primary" [disabled]="formGroup.invalid" (click)="window.alert('Thanks for your submission!')>Submit</button>
What am I doing wrong?
Upvotes: 1
Views: 6001
Reputation: 83
In your component.ts file you can say
window = window;
And then use window
in your component.html as you would anywhere else
<button (click)="window.alert('Hello world')">
This is a button
</button>
Upvotes: 1
Reputation: 86
You can not access "window" from the component.html file.
Instead, try creating an alert function in your component.ts file like so:
alert() {
window.alert('test');
}
Then run the alert()
function:
<button mat-raised-button matStepperNext color="primary" [disabled]="formGroup.invalid" (click)="alert()">Submit</button>
Upvotes: 7