ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
59 lines (51 loc) • 1.51 kB
text/typescript
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
EventEmitter,
Input,
OnDestroy,
OnInit,
Output,
ViewEncapsulation,
} from '@angular/core';
import { OhayoLocaleService, LocaleData } from '@ohayo/theme';
import { BooleanInput, InputBoolean } from '@ohayo/util';
import { Subscription } from 'rxjs';
export class TagSelectComponent implements OnInit, OnDestroy {
static ngAcceptInputType_expandable: BooleanInput;
private i18n$: Subscription;
locale: LocaleData = {};
expand = false;
/** 是否启用 `展开与收进` */
expandable = true;
// tslint:disable-next-line:no-output-native
readonly change = new EventEmitter<boolean>();
constructor(private i18n: OhayoLocaleService, private cdr: ChangeDetectorRef) { }
ngOnInit(): void {
this.i18n$ = this.i18n.change.subscribe(() => {
this.locale = this.i18n.getData('tagSelect');
this.cdr.detectChanges();
});
}
trigger(): void {
this.expand = !this.expand;
this.change.emit(this.expand);
}
ngOnDestroy(): void {
this.i18n$.unsubscribe();
}
}