This line of code: <p (click)="${open()}">Open</p>
is building a string. And ${open()}
is the syntax to insert the results of executed code into the string.
So, it runs the code open()
and then inserts the results of that function call into the string.
I'm not familiar with the syntax of angular or how you're expected to add an event listener to an element. But I can assure you what you're doing isn't it. You need either a reference to a name of a function, or you need an inline string of javascript to execute, where angular is either providing you with some special component closure, or something like that. Meaning, without Angular you would do:
Actual reference to function:
myParagraphElement.addEventListener('click', open.bind(this))
[OR]
Textual line of javascript to execute:
<p onClick="open()">Click Me</p> // Where open was on the window
I assume the angular syntax you're using with (click)
should be a textual line of javascript to execute like <p (click)="open()">Click</p>
, and that angular would assume the method is either on the class, or "angular component" with regards to context. But I'm guessing that would only work in whatever "template" HTML you are using, as opposed to just generating a string. But without seeing all of your code, I wouldn't be able to guess.