问题
我有4个静态页面与完整的角度6 web应用程序,我想渲染home.html页面在开始和登录后,重定向到实际的角网页应用程序,从那里角路由激发和做魔术。问题是我为什么要这个?我想要这个,因为我的网页应用有一些静态页面,如主页,联系我们,我想要条款和条件和隐私政策等。我希望这个网页是静态的爬虫友好和快速渲染排除它的角度。
问题
我怎么能做到这一点。
迄今已完成
我在index.html所在的根目录中创建了3个静态页面。在角度上我把这条线
"index": "src/home.html",但是现在我无法导航到contactus.html页面,它向我显示了这个错误。
错误
"The selector "app-root" did not match any elements"发布于 2018-10-16 11:56:06
如果我对您的理解是正确的,您可以使用“路由”映射您的页面,并在相同的“索引”中显示您的所有内容。是通用的,因为有了它,您可以管理许多事情,比如会话访问:我向您展示了一个示例:
app.module.ts
import { Routes, RouterModule } from '@angular/router';
/*Example component*/
import { InicioComponent } from './inicio/inicio.component';
import{ ExamplePage } from './page1/examplePage.component';
/*Routes mapping*/
const routes: Routes = [
{path: '', component: InicioComponent },
{path: 'proveedores', component: ExamplePage, canActivate: [GuardService] }] /* Example of protected by session page*/
@NgModule({
declarations: [
ExamplePage,
InicioComponent
],
imports: [
RouterModule.forRoot(routes)
]app.component.html
<h1>Angular</h1>
<hr>
<hr>
<app-header></app-header>
<div class="container text-center">
<router-outlet>**Here are all the pages**</router-outlet>
</div>这只是一个简短的例子,很复杂,这里对此做了深入的解释,但是在angular.io中有很多关于这个模块的文档:https://angular.io/guide/router。
https://stackoverflow.com/questions/52817008
复制相似问题