Angular: Can a click event run a single statement?

Viewed 3393

In Angular 4, is it possible to execute code in a click event without writing a function for it? e.g.

<button (click)="bool=true; console.log("print"); Function()">Button1</button>

After doing a little reading the reason this may not be possible is that an html element, button in this case, belongs to the typescript component, not the html template, and so you wouldn't have code outside of a function there. But... I'm not sure if that's even close to a right understanding.

Edit:

This post, console.log not working in Angular2 Component (Typescript) , answers the issue with console.log, but still leaves some explanation to be desired in some other cases, such as

<button (click)="bool=true">Button1</button>

The accepted answer explains the limitations of this.

2 Answers
Related