我想知道你是怎么改变观点的。如果我想在index.html中显示不同的东西(改变视图),我该怎么做呢?
使用视图的方法是否已被使用组件和模板所取代?
到目前为止,我的app.module中有这样的内容:
const appRoutes: Routes = [
{
path: '',
component: HomeComponent
},
{
path: 'construction',
component: ConstructionComponent
},
{
path: '**',
component: PageNotFoundComponent
}
];发布于 2016-12-16 14:29:05
视图只是一个HTML文件,其中有一个Controller链接到它。这在Angular 2中并没有什么不同。
不再在配置文件中定义HTML View,定义Component (相当于Controller),View现在直接在Component中定义。
因此,为了澄清,您必须定义一个路径和一个Component,它将呈现您想要的View。就像以前一样。不要犹豫,查看关于路由的官方文档
https://stackoverflow.com/questions/41186393
复制相似问题