在当前组件中动态加载Angular6组件,以在当前模板中使用

时间:2018-07-09 14:17:54

标签: angular module lazy-loading

我有一个组件,可以在用户登录时在模板中显示某些额外的组件。但是,如果用户从未登录,我根本不想从服务器加载这些组件。我仍然需要它们放在模板中,如下所示:

<p>
This is the regular page, showing to the normal user.
</p>

<!-- The following component should only be shown and LOADED if the user is logged in -->
<app-admin-show-extra-content *ngIf="adminService.isLoggedIn()"></app-admin-show-extra-content>

在这种情况下,我需要在模板中包含组件,但是如果用户尚未登录,则不应显示或加载这些组件。这可能吗?

0 个答案:

没有答案