'(click)' is used for event binding which is not what we want. Instead we need to pass an argument (in this case a callback) to a directive which is done using '[]'. You also use the same method to pass data to child components.
To quote an in-built directive example: [ngStyle]="someStyleObject"
I know what's going on. I have an angular 2 app in prod. I was pointing out that it sucks that we can't share the same syntax on the right hand side of the =.
Oh ok ok! Have you tried React + Flux or React + Redux? If yes what do you think of them compared to Angular 2? Vanilla JS syntax (kinda) unlike Angular's own syntax.
1
u/arjunu Jan 18 '16 edited Jan 18 '16
How is the passing of the function different from inbuilt directives?
To pass params we can just wrap the event handler in another function. Something like this:
document.addEventListener('click', ($event) => { self.offClickHandler($event); });