I have simple click event binding
@Component({template:` <div ({{eventStr}})="do-log()">DoLog</div>`})
export class AppComponent {
eventStr:string="click";
do-log(){
console.log("ckp");
}
}
of course it will work if change ({{eventStr}}) to (click) .I try many way like (${eventStr}) ,(eventStr). I don't understand ,inside (click)="do-log()" ,this click is not string or what other type?
I want to use eventStr instead of click because I want to change event type dynamic,e.g. swipe.
Update:
I know there are two way @HostBinding and renderer.listen, but I have different use case and find some way like this: in parent component template like:
<child-cmp eventType="swipe">Swipe</child-cmp><child-cmp eventType="click">Click</child-cmp>
and in child component template like:
<div><button (eventType)="dosomething_accordingTo_diff_touch_events()"></button></div>
of course with @Input eventType:string. It doesn't work. I guess if eventType is not a string but an event object, in fact (eventType)==("swipe") or==("click"), not equal to (swipe) or (click). so is there one way to let (eventType)==(swipe) inside template?