ngx-app-version
Version:
Angular directive for writing version into DOM
44 lines (38 loc) • 1.55 kB
JavaScript
import * as i0 from '@angular/core';
import { InjectionToken, inject, ElementRef, Renderer2, Directive } from '@angular/core';
const APP_VERSION_OPTIONS_TOKEN = new InjectionToken('[ngxAppVersion] Options');
const provideAppVersion = (options) => {
return {
provide: APP_VERSION_OPTIONS_TOKEN,
useValue: {
version: options.version
}
};
};
/**
* @returns app version
*/
class NgxAppVersionDirective {
options = inject(APP_VERSION_OPTIONS_TOKEN);
element = inject(ElementRef);
renderer = inject(Renderer2);
ngOnInit() {
this.renderer.setAttribute(this.element.nativeElement, 'app-version', this.options.version);
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: NgxAppVersionDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0", type: NgxAppVersionDirective, isStandalone: true, selector: "[ngxAppVersion]", ngImport: i0 });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: NgxAppVersionDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngxAppVersion]'
}]
}] });
/*
* Public API Surface of ngx-app-version
*/
/**
* Generated bundle index. Do not edit.
*/
export { APP_VERSION_OPTIONS_TOKEN, NgxAppVersionDirective, provideAppVersion };
//# sourceMappingURL=ngx-app-version.mjs.map