ng2-materialize
Version:
An Angular 2+ wrap around Materialize library
29 lines (28 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var MzRemoveComponentHost = (function () {
function MzRemoveComponentHost(elementRef) {
this.elementRef = elementRef;
this.childrenElement = [];
}
MzRemoveComponentHost.prototype.ngAfterViewInit = function () {
var hostElement = this.elementRef.nativeElement;
this.parentElement = hostElement.parentElement;
// move child out of the host element
while (hostElement.firstChild) {
this.childrenElement.push(this.parentElement.insertBefore(hostElement.firstChild, hostElement));
}
};
MzRemoveComponentHost.prototype.ngOnDestroy = function () {
var _this = this;
// remove moved out element
this.childrenElement.forEach(function (childElement) { return _this.parentElement.removeChild(childElement); });
};
return MzRemoveComponentHost;
}());
/** @nocollapse */
MzRemoveComponentHost.ctorParameters = function () { return [
{ type: core_1.ElementRef, decorators: [{ type: core_1.Inject, args: [core_1.ElementRef,] },] },
]; };
exports.MzRemoveComponentHost = MzRemoveComponentHost;