bia-framework
Version:
Bia Framework to work with angular 2
67 lines (51 loc) • 2.06 kB
text/typescript
import {
Component,
ViewEncapsulation,
ComponentResolver,
ViewChild,
ViewContainerRef
} from "@angular/core";
import {NgIf, NgClass} from "@angular/common";
import {CoreDialogService, ICoreDialogArguments} from "./core-dialog.service";
import {CoreIcon} from "../core-icon/core-icon";
declare var System:any;
export class CoreDialog {
private isProcessing:boolean = false;
private isVisible:boolean = false;
private hasBackButton:boolean = false;
private tittle:string;
private backgroundColor:string;
container:ViewContainerRef;
constructor(private coreDialogService:CoreDialogService, private resolver:ComponentResolver) {
this.coreDialogService.onShow.subscribe((newRequest)=> this.showDialog(newRequest));
};
public back = ():void => {
this.coreDialogService.back();
this.isVisible = false;
this.container.remove();
//TO-DO REMOVER DEPOIS
console.log("container removido...");
};
private showDialog = (request:ICoreDialogArguments):void => {
this.isProcessing = true;
this.isVisible = true;
this.backgroundColor = request.backgroundColor || "white";
this.hasBackButton = request.hasBackButton || false;
this.tittle = request.tittle || "";
System.import(request.path).then(c => c[request.className]).then((result)=> {
this.resolver.resolveComponent(result).then(factory => {
this.container.createComponent(factory, 0, this.container.injector);
});
});
};
}