ngSemantic
ngSemantic copied to clipboard
<sm-message> closing
sm-message component would be even better with a (onClose) event so we could perform some garbage collection when they close out. Also, when you call 'detachView'...does this remove the element from the DOM? It doesn't look it does to me...was that your intention? Maybe it should be destroyView?
EDIT: I wanted to do a pull request, but when I cloned your project and followed the dev intructions...I'm getting this error:
[0] > tsc -w -p './demo'
[0]
[0] error TS5058: The specified path does not exist: ''./demo''
0] npm ERR! node v5.4.1
[0] npm ERR! npm v3.10.6
[0] npm ERR! code ELIFECYCLE
[0] npm ERR! [email protected] tsc:w: `tsc -w -p './demo'`
[0] npm ERR! Exit status 1
[0] npm ERR!
[0] npm ERR! Failed at the [email protected] tsc:w script 'tsc -w -p './demo''.
Anyways, here is my suggestion for sm-message. I have not tested this, but it's pretty straight forward.
export class SemanticMessageComponent {
@Input() icon: string;
@Input() class: string;
@Output() onClose: EventEmitter<any> = new EventEmitter();
@ViewChild("message") message: ElementRef;
constructor(public renderer: Renderer) {}
close() {
this.renderer.detachView([this.message.nativeElement]);
this.onClose.emit(null);
}
}