Html 新建角度项目如何设置主页
我是新手 我已使用此链接创建了新项目Html 新建角度项目如何设置主页,html,angular,typescript,Html,Angular,Typescript,我是新手 我已使用此链接创建了新项目https://cli.angular.io/ 这里显示的主页来自appcomponent.html 我已经在SRC>>pages>>index.html和index.ts中创建了新页面 我在appcomponent.ts和appmodule.ts 如何将默认主页设置为索引 这是我的应用程序组件页面 import { Component } from '@angular/core'; import { Http, Headers } from '@angula
https://cli.angular.io/
这里显示的主页来自appcomponent.html
我已经在SRC>>pages>>index.html和index.ts中创建了新页面
我在appcomponent.ts
和appmodule.ts
如何将默认主页设置为索引
这是我的应用程序组件页面
import { Component } from '@angular/core';
import { Http, Headers } from '@angular/http';
import { IndexPage } from '../pages/index';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class MyApp {
title = 'app';
rootPage:any = IndexPage;
constructor( public http: Http ) {
}
}
您必须使用ng g c MyComponent生成一个新组件。然后加上
到您的app.component.html文件。最后,您必须将路由器配置为在主地址(localhost:4200)显示此组件。对象应该是
const routesConfig: Routes = [
{ path: '', component: MyComponent}
]
阅读app-rounting.module.ts中有关路由器和路由的更多信息
{path: "", component: DashboardComponent, pathMatch: "full"},
为什么棱角如此神秘?