Closed senzacionale closed 4 years ago
Hello, yes of course you can open a component inside a modal.
Like here => https://stackblitz.com/edit/angular-ws258v
You may have forgotten to import this component into your module 😄
No I import it. But the content is not shown. Can you provide whole example. And my component has another component call inside ...
Look at https://stackblitz.com/edit/angular-ws258v
I updated it with your code
Thank you. Maybe is problem because I am not loading static but dynamic data in component. I need to reinitialize ngOnInit() method after modal is open and prepare data.
ngOnInit() is currently not executed after modal is open.
Can you give me an exemple of your problem on stackblitz please ?
I will try to prepare it.
In the meanwhile. Can you test if in TradingViewComponent class ngOnInit will be executed after modal is open?
I just tested it and it is not
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
@Component({
selector: 'tradingview',
template: `
<h1>I'm a component inside another component</h1>
`,
styles: [`h1 { background-color: red; }`]
})
export class TradingViewComponent implements OnInit, OnDestroy {
ngOnInit() {
alert('test')
}
ngOnDestroy() {
}
}
It's because I import it on app.module, then he init on start of application. If you want to init the composant on modal open. Just add a ngIf condition on the component.
<tradingview *ngIf="modalData.visible"></tradingview>
@senzacionale Is there still a need to keep this issues open?
Hey. Sorry for delay. It is working very well. Thank you!
I really like your smart modal. But I have one question.
I would like to open another component inside your modal.
Example:
tradingview is my component.
But the problem is that is never called and executed.