mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-14 21:06:34 +03:00
37 lines
821 B
TypeScript
37 lines
821 B
TypeScript
'use strict';
|
|
|
|
import { Component, EventEmitter, ElementRef, Output, AfterContentInit } from '@angular/core';
|
|
import { CORE_DIRECTIVES } from '@angular/common';
|
|
import DropKick from 'dropkickjs';
|
|
|
|
@Component({
|
|
selector: 'drop-down',
|
|
template: `
|
|
<select (change)=onChange($event.target.value)>
|
|
<ng-content></ng-content>
|
|
</select>
|
|
`,
|
|
directives: [CORE_DIRECTIVES],
|
|
styleUrls: ['./drop-down.css']
|
|
})
|
|
export class DropDown implements AfterContentInit {
|
|
@Output() change = new EventEmitter();
|
|
elem: any;
|
|
inst: any;
|
|
constructor(elem:ElementRef) {
|
|
this.elem = elem.nativeElement;
|
|
}
|
|
|
|
ngAfterContentInit() {
|
|
this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true});
|
|
}
|
|
|
|
onChange(value) {
|
|
this.change.next(value);
|
|
}
|
|
|
|
destroy() {
|
|
this.inst.dispose();
|
|
}
|
|
}
|