[英]Angular - Is it possible to create a pop up of the AppComponent?
Just curious. 只是好奇。 1. In Angular 6, Is it possible to create a pop up of the AppComponent in another component?
1.在Angular 6中,是否可以在另一个组件中创建AppComponent的弹出窗口? I think it is quite possible.
我认为这很有可能。
constructor(private dialogRef: MatDialogRef){} Something like this 构造函数(private dialogRef:MatDialogRef){}这样的东西
Yes this is possible. 是的,这是可能的。 You can create a component and then use that component wherever you want in your application.
您可以创建一个组件,然后在您的应用程序中的任何位置使用该组件。
One option to display it as a popup would be to call a modal which loads that component as it's content. 将其显示为弹出窗口的一个选项是调用一个模态,该模式加载该组件作为其内容。
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" data-backdrop="static" aria-hidden="true">
<app-myComponent></app-myComponent>
</div>
Then to call the modal from something like a button you can use a function: 然后从像按钮这样的东西调用模态你可以使用一个函数:
showMyModal() {
$('#myModal').modal();
}
To display it as a regular component you can use it as you would any other component when placing these on a page. 要将其显示为常规组件,您可以像将任何其他组件放在页面上一样使用它。 EG:
例如:
<div class="main-panel">
<app-navbar></app-navbar>
<router-outlet></router-outlet>
<app-myComponent></app-myComponent>
<app-footer></app-footer>
</div>
I recommend the Angular tutorial at https://angular.io/tutorial 我推荐使用https://angular.io/tutorial上的Angular教程
It is very short and really helps you understand how components work and how to use them. 它非常简短,真正帮助您了解组件的工作原理以及如何使用它们。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.