0
我有一个菜单栏和操作面板。操作面板只是简单的div,其中我想要显示不同的组件。如何在运行时动态更改组件模板? Angular 4
例如: 用户单击按钮A - >在操作面板中显示组件A; 用户单击按钮B - >在操作面板中显示组件B;
这样做的最好方法是什么?
我想在我的模板中使用ngswtich,例如(伪代码!)。
<div id="action-panel">
<div [ngSwitch]="componentType">
<div *ngSwitchCase="userComponent">
<user-component></user-component>
</div>
</div>
</div>
您可以使用路由到这一点,你可以通过不同的视图导航可能的复制。 更多信息,请访问https://angular.io/guide/router –