[英]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.
ngOnInit 不需要很长时间就可以到达。 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. ngOnInit 不起作用。 why?
为什么?
Check if MyComponent.ngOnInit
will be called when you invoke c method.检查调用 c 方法时是否会调用
MyComponent.ngOnInit
。 MatDialog
will create this component in runtime in response to event which will call show
method MatDialog
将在运行时创建此组件以响应将调用show
方法的事件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.