ng-semantic
Version:
Angular2 building blocks based on Semantic UI
38 lines (32 loc) • 1.08 kB
text/typescript
import {
Component, ChangeDetectionStrategy, Input, AfterViewInit, ViewChild, ElementRef, Output, EventEmitter
} from "@angular/core";
declare var jQuery: any;
({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: "sm-dropdown",
template: `
<div class="ui {{class}} dropdown item" #dropdown>
<div *ngIf="title" class="text">{{title}}</div>
<i class="dropdown icon"></i>
<div class="menu">
<ng-content></ng-content>
</div>
</div>
`
})
export class SemanticDropdownComponent implements AfterViewInit {
() class: string;
() title: string;
() items: Array<{}>;
() options: {} = {};
() onChange: EventEmitter<string|number> = new EventEmitter<string|number>();
("dropdown") dropdown: ElementRef;
ngAfterViewInit(): void {
const options: {} = Object.assign(this.options, {
onChange: (value: string|number) => this.onChange.emit(value)
});
jQuery(this.dropdown.nativeElement)
.dropdown(options);
}
}