import { LoadingService } from '@farris/ui-loading'; import { Subject } from 'rxjs/Subject'; import { Observable } from 'rxjs/Observable'; import { Component, Renderer2, TemplateRef, ViewChild, ComponentFactoryResolver, Injector, ComponentRef, ElementRef } from '@angular/core'; import { BsModalService } from '../../../../../projects/modal/src/public-api'; import { MessagerService } from '../../../../../projects/messager/src/public-api'; import { BsModalRef } from '../../../../../projects/modal/src/public-api'; import { DialogContentComponent } from './dialog-content.component'; import { of } from 'rxjs/observable/of'; @Component({ selector: 'app-dialog-demo', templateUrl: `./dialog-demo.component.html` }) export class DialogDemoComponent { @ViewChild('buttonRef2') btnRef: TemplateRef; dlg: BsModalRef; constructor( private modalService: BsModalService, private injector: Injector, private cfr: ComponentFactoryResolver, private msgService: MessagerService, private loadingSer: LoadingService ) { } showDialog() { this.dlg = this.modalService.show(DialogContentComponent, { title: 'AAAAAA', width: 500, height: 600, // buttons: this.btnRef, showButtons: false, beforeClose: (ref) => { console.log(ref); const canClose = new Subject(); this.msgService.question('确认要关闭此窗口吗? 亲.', () => { canClose.next(true); }, () => { canClose.next(false); }); return canClose.asObservable(); } }); // const instance = this.dlg.content as DialogContentComponent; // console.log(instance.content, this.dlg); } showDialog2() { const cmpF = this.cfr.resolveComponentFactory(DialogContentComponent); const cmpR = cmpF.create(this.injector); this.dlg = this.modalService.show(cmpR, { title: 'BBBBB', width: 500, height: 600, buttons: this.btnRef, showButtons: false }); } showDialog4() { const cmpF = this.cfr.resolveComponentFactory(DialogContentComponent); const cmpR = cmpF.create(this.injector); this.dlg = this.modalService.show(cmpR, { title: 'BBBBB', width: 500, height: 600, buttons: this.btnRef, showButtons: true }); } showDialog3() { this.dlg = this.modalService.show(DialogContentComponent, { title: 'AAAAAA', width: 500, height: 600, buttons: [ { text: 'info', cls: 'btn btn-info', }, { text: 'primary', cls: 'btn btn-primary'}, { text: 'secondary', cls: 'btn btn-secondary'}, { text: 'success', cls: 'btn btn-success'}, { text: 'danger', cls: 'btn btn-danger'}, { text: 'warning', cls: 'btn btn-warning'}, { text: 'CLOSE', cls: 'btn btn-outline-secondary', handle: () => { this.dlg.close(); }} ], showButtons: true, beforeClose: () => { const canClose = new Subject(); this.msgService.question('确认要关闭此窗口吗? 亲.', () => { canClose.next(true); }, () => { canClose.next(false); }); return canClose.asObservable(); } }); } showCustomMsg() { this.msgService.show('warning', `登录失败
请检查用户名或密码是否正确!
登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,\r\n 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确! 登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败, 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败, 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确! 登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败, 登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败, 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确! 登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确! 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败, 请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确! 登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!登录失败,请检查用户名或密码是否正确!`, { width: 600, height: 400, title: '标题还是要有的,万一被登TD就不好了,您说是吧' }); } }