1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-21 02:33:46 +00:00

directives

This commit is contained in:
Kyle Spearrin
2018-01-23 23:38:56 -05:00
parent e06704431a
commit 5703782a0f
10 changed files with 59 additions and 3 deletions

View File

@@ -0,0 +1,20 @@
import {
Directive,
ElementRef,
HostListener,
Input,
} from '@angular/core';
@Directive({
selector: '[appFallbackSrc]'
})
export class FallbackSrcDirective {
@Input('appFallbackSrc') appFallbackSrc: string;
constructor(private el: ElementRef) {
}
@HostListener('error') OnError() {
this.el.nativeElement.src = this.appFallbackSrc;
}
}

View File

@@ -0,0 +1,13 @@
import {
Directive,
HostListener,
} from '@angular/core';
@Directive({
selector: '[appStopClick]'
})
export class StopClickDirective {
@HostListener('click', ['$event']) onClick($event: MouseEvent) {
$event.preventDefault();
}
}

View File

@@ -0,0 +1,13 @@
import {
Directive,
HostListener,
} from '@angular/core';
@Directive({
selector: '[appStopProp]'
})
export class StopPropDirective {
@HostListener('click', ['$event']) onClick($event: MouseEvent) {
$event.stopPropagation();
}
}