Reputation: 5473
I'm trying to do this:
<button (click)="confirm('some message') ? someFunction() : anotherFunction()">Text</button>
This of course fails, because Angular looks for the confirm() function within its own code. It fails compilation with an error statement like so:
ERROR in src\client\pages\x.component.html(72,114): : Property 'confirm' does not exist on type 'OurCustomComponent'.
Is there a way to make this work? I do realize (having just read the documentation now), that some javascript syntax is disallowed, but it's unclear if there's a way to accomplish this or not.
Upvotes: 1
Views: 35
Reputation: 13584
you need a wrapper function in the component.
confirm(): void {
confirm('some message') ? this.someFunction() : this.anotherFunction();
}
<button (click)="confirm()">Text</button>
Upvotes: 1