I'm developing Angular 2 + TypeScript app with modal dialogs.
I have main modal component:
<div class="modal">
<div class="header">{{title}}</div>
<div class="body">{{body}}</div>
<div class="footer">{{footer}}</div>
</div>
where {{title}}
- text, {{body}}
and {{footer}}
- html from different components.
And in component that contains button to open modal dialog I have this:
import { Component } from '@angular/core';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { ModalComponent } from './modal.component';
import { BodyOneComponent } from './body/body-one.component';
import { FooterOneComponent } from './footer/footer-one.component';
@Component({
selector: 'ac-parent',
templateUrl: './app/parent.component.html'
})
export class ParentComponent {
constructor(private modalService: NgbModal) { }
openModal() {
const modalRef = this.modalService.open(ModalComponent);
modalRef.componentInstance.title = "Modal title";
modalRef.componentInstance.body = "get html from BodyOneComponent somehow";
modalRef.componentInstance.footer = "get html from FooterOneComponent somehow";
}
}
So, my problem is how can I get html content of component from other component? And how can I compile those html into one view? What is the best approach for doing that? Should I use something different from template expression?