【发布时间】:2018-01-09 18:27:58
【问题描述】:
我正在使用 ngx-bootstrp Modals。我必须使用嵌套的service-component 模态来满足特定要求。我已经制作了现场演示来展示问题。
我希望(例如)全名出现在模态中,名字来自第一个模态,姓氏来自第二个模态,并作为用户输入进行更新。
import { Component, TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent{
modalRef: BsModalRef;
constructor(private modalService: BsModalService) {}
person:any={}
openModal(template: TemplateRef<any>) {
this.modalRef = this.modalService.show(template);
}
openModalWithComponent() {
this.modalRef = this.modalService.show(ModalContentComponent);
this.modalRef.content.title = 'Modal with component';
}
}
/* This is a component which we pass in modal*/
@Component({
selector: 'modal-content',
template: `
<div class="modal-header">
<h4 class="modal-title pull-left">{{title}}</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="modalRef.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<input type="text" placeholder="Last Name">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" (click)="modalRef.hide()">Close</button>
</div>
`
})
export class ModalContentComponent {
title: string;
constructor(private modalService: BsModalService) {}
}
我发现这个SO 帖子发现是相似的,它不是完全满足我的要求。
如何达到以上要求?
感谢您的宝贵时间..
【问题讨论】:
标签: angular ngx-bootstrap