redoc/lib/shared/components/DropDown/drop-down.ts

37 lines
770 B
TypeScript
Raw Normal View History

2016-04-19 18:50:01 +03:00
'use strict';
import {Component, EventEmitter, ElementRef, Output} from '@angular/core';
2016-05-05 11:05:02 +03:00
import {CORE_DIRECTIVES} from '@angular/common';
import DropKick from 'dropkickjs';
2016-04-19 18:50:01 +03:00
@Component({
selector: 'dropdown',
template: `
<select (change)=onChange($event.target.value)>
<ng-content></ng-content>
</select>
`,
directives: [CORE_DIRECTIVES],
styleUrls: ['./drop-down.css']
2016-04-19 18:50:01 +03:00
})
export class DropDown {
@Output() change = new EventEmitter();
elem: any;
inst: any;
constructor(elem:ElementRef) {
2016-04-19 18:50:01 +03:00
this.elem = elem.nativeElement;
}
ngAfterContentInit() {
2016-06-06 19:32:20 +03:00
this.inst = new DropKick(this.elem.firstElementChild, {autoWidth: true});
2016-04-19 18:50:01 +03:00
}
onChange(value) {
this.change.next(value);
}
destroy() {
this.inst.dispose();
}
}