在Angular 8中,启动页面是由app.module.ts
文件中的bootstrap
属性来确定的。
首先,在app.module.ts
文件中,导入NgModule
装饰器和BrowserModule
模块:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
然后,在@NgModule
装饰器的bootstrap
属性中,指定你想要作为启动页面的组件。例如,假设你想要将AppComponent
作为启动页面:
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
bootstrap: [AppComponent] // 设置启动页面
})
export class AppModule { }
注意,你需要在declarations
数组中引入AppComponent
,并在imports
数组中引入BrowserModule
模块。
最后,确保在main.ts
文件中,调用platformBrowserDynamic().bootstrapModule(AppModule)
方法来启动应用程序。
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
这样,Angular 8应用程序就会使用AppComponent
作为启动页面。