ng-semantic
Version:
Angular2 building blocks based on Semantic UI
46 lines (37 loc) • 1.13 kB
text/typescript
import {
Component, ChangeDetectionStrategy, ViewChild, ElementRef, Input, Output, EventEmitter,
AfterViewInit
} from "@angular/core";
declare var jQuery: any;
({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: "sm-shape",
template: `
<div #shape class="ui shape {{class}}">
<ng-content></ng-content>
</div>
`
})
export class SemanticShapeComponent implements AfterViewInit {
() class: string;
() options: {} = {};
() beforeChange: EventEmitter<boolean> = new EventEmitter<boolean>();
() onChange: EventEmitter<boolean> = new EventEmitter<boolean>();
("shape") shape: ElementRef;
ngAfterViewInit() {
Object.assign(this.options, {
beforeChange: (): void => this.beforeChange.emit(true),
onChange: (): void => this.onChange.emit(true)
});
}
/**
* Show shape element
*
* @param args
*/
show(...args: string[]) {
jQuery(this.shape.nativeElement)
.shape(this.options)
.shape(args.join(","));
}
}