【发布时间】:2020-02-21 10:38:29
【问题描述】:
我已经创建了一个 Angular 应用程序,为此,如果用户指向一个未知的 URL,它应该进入一个 404 页面,显示一条友好的消息以重定向到主页。 现在我创建了一个显示这个 404 的组件。现在的问题是,它显示了页眉和页脚。在这种情况下,我不希望显示页眉和页脚 The page right now 我需要显示没有页眉和页脚的 404。有没有简单的方法来实现它。提前致谢。
索引.html
<body>
<app-root></app-root>
</body>
app.component.html
<div *ngIf="!webLoading">
<app-header></app-header>
<div class="minhgt-router-outlet">
<router-outlet></router-outlet>
</div>
<app-footer></app-footer>
</div>
<div class='modal d-flex carousel' *ngIf="webLoading">
<p-progressSpinner [style]="{width: '50px', height: '50px'}"
strokeWidth="4" fill="#ffffff" animationDuration=".8s"></p-progressSpinner>
</div>
not-found.component.html
<div class="notfound">
<div class="notfound-404">
<h3>Oops! Page not found</h3>
<h1>
<span>4</span>
<span>0</span>
<span>4</span>
</h1>
</div>
<h2>we are sorry, but the page you requested was not found</h2>
</div>
app-routing.module.ts
const routes: Routes = [
{
path: "",
component: BodyContentComponent
},
{
path: "**",
component: NotFoundComponent
}
];
【问题讨论】:
-
什么是 webLoading ?
-
@A.khalifa 这只是在我们得到 API 响应之前显示的微调器
标签: angular angular8 angular-routing angular-router