2016-04-19 18:50:01 +03:00
|
|
|
'use strict';
|
|
|
|
|
2016-06-15 21:48:04 +03:00
|
|
|
import { Component, EventEmitter, ElementRef, Output, AfterContentInit } from '@angular/core';
|
2016-08-28 21:46:10 +03:00
|
|
|
import * as DropKick from 'dropkickjs';
|
2016-04-19 18:50:01 +03:00
|
|
|
|
|
|
|
@Component({
|
2016-06-15 21:48:04 +03:00
|
|
|
selector: 'drop-down',
|
2016-04-19 18:50:01 +03:00
|
|
|
template: `
|
|
|
|
<select (change)=onChange($event.target.value)>
|
|
|
|
<ng-content></ng-content>
|
|
|
|
</select>
|
|
|
|
`,
|
2016-05-25 18:34:31 +03:00
|
|
|
styleUrls: ['./drop-down.css']
|
2016-04-19 18:50:01 +03:00
|
|
|
})
|
2016-06-15 21:48:04 +03:00
|
|
|
export class DropDown implements AfterContentInit {
|
2016-05-25 18:34:31 +03:00
|
|
|
@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();
|
|
|
|
}
|
|
|
|
}
|