I was having kittens about the number of global Angular change detections every time an event goes off, and I found Angular 2 runOutsideAngular still change the UI and I adopted the 'OutSideEventHandlerDirective' strategy.
However, now I have a file with 6 directives in it, each for a different event type.
What I'd like to do is pass the event type into the directive; i.e. set @Input() event: string = 'my event type' inside the directive from the template html.
Is this even possible?
So, thankyou for the answers so far. Added as an edit to have nicer presentation than a comment:
Things to learn:
1/ @input () xyz: string = 'hello' - you can set this input in the template using (outSideEventHandler)="onEv($event)" [xyz]="goodbye"
2/ @input ('abc') xyz: string = 'hello' - 'renames' the thing you use to refer to the input, i.e. now you use [abc]="goodbye"
Addition to the question:
3/ I have use of two or more of these 'outside' directives on the same element. if you have (outSideEventHandler)="onEvent1($event)" [event]="mousedown" (outSideEventHandler)="onEvent2($event)" [event]="mouseup" - then you get two copies of the directive, but both use event=mousedown.
I can create two (or more) copies of the directive (see code), and then have separate unique named inputs for each. But is this the only way:?
(outSideEventHandler1)="onTestDirective($event)"
[outSideEvent1]="'mousedown'"
(outSideEventHandler2)="onTestDirective($event)"
[outSideEvent2]="'mouseup'"