mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
directives
This commit is contained in:
20
src/app/directives/fallback-src.directive.ts
Normal file
20
src/app/directives/fallback-src.directive.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
13
src/app/directives/stop-click.directive.ts
Normal file
13
src/app/directives/stop-click.directive.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
13
src/app/directives/stop-prop.directive.ts
Normal file
13
src/app/directives/stop-prop.directive.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user