import { Directive , ElementRef , HostBinding , HostListener , OnInit , Optional } from '@angular/core' ; import { CardComponent } from '../../components/card/card.component' ; @ Directive ( { selector : 'kirby-card[click]' , } ) export class ElementAsButtonDirective implements OnInit { @ HostBinding ( 'attr.role' ) role : string = 'button' ; @ HostBinding ( 'attr.tabindex' ) tabindex : number = 0 ; constructor ( @ Optional ( ) private card , private clickableElement ) { } ngOnInit ( ) { if ( this . card ) { this . card . flat = false ; } } @ HostListener ( 'keydown.space' , [ '$event' ] ) @ HostListener ( 'keydown.enter' , [ '$event' ] ) _onKeydownHandler ( event ) { this . clickableElement . nativeElement . click ( event ) ; } }