'Why ngOnInit doesn't work if i open component from MatDialog?
Why the component may get stuck after constructor? ngOnInit does not take a very long time to reach. If there is a random change to store, for example, then the component loading continues
If I declare like this:
<app-my-component></app-my-component>
everything is work. but if I do like this:
public show(someData:SomeData) {
const config: MatDialogConfig = {
hasBackdrop: true,
data: {
someData,
},
};
this.matDialog.open(MyComponent, config);
}
ngOnInit doesn't work. why?
Solution 1:[1]
Check if MyComponent.ngOnInit will be called when you invoke c method. MatDialog will create this component in runtime in response to event which will call show method
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Yaroslav Horbachov |
