官术网_书友最值得收藏!

Prepare to bootstrap the AppModule 

We now have a good setup for our feature modules and it's time to bring them all together in our root AppModule responsible for bootstrapping our app. 


Bootstrap only what is needed for your initial view. Lazy load the rest.

It's important to keep the bootstrap of our app as fast as possible. To achieve that, we only want to bootstrap the app with the main features needed for our initial view and lazy load the rest when needed. We know we want our low-level services to be available and ready to use anywhere in the app, so we will definitely want CoreModule upfront.

Our initial view from our sketch is going to start with the player and 2-3 tracks on the list, so the user can immediately playback a mix of pre-recorded tracks we will ship with the app for demonstration purposes. For this reason, we will specify the PlayerModule to load upfront when our app bootstraps, since it will be a primary feature we want to immediately engage with.

We will set up a routing configuration, which will lazy load our RecorderModule when the user taps the record button at the top right of our initial view to begin a recording session.

With this in mind, we can set up our AppModule located at app/app.module.ts, as follows:

// angular 
import { NgModule } from '@angular/core';

// app
import { AppComponent } from './app.component';
import { CoreModule } from './modules/core/core.module';
import { PlayerModule } from './modules/player/player.module';

@NgModule({
imports: [
CoreModule,
PlayerModule
],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule { }
主站蜘蛛池模板: 徐汇区| 牙克石市| 突泉县| 绥棱县| 时尚| 利辛县| 平安县| 南通市| 宜昌市| 洛扎县| 乌兰察布市| 宕昌县| 翁源县| 子洲县| 彭阳县| 安塞县| 湄潭县| 普兰店市| 沁源县| 阿勒泰市| 漾濞| 曲靖市| 海南省| 乌拉特中旗| 尚志市| 本溪| 崇阳县| 德惠市| 吉木萨尔县| 东方市| 额尔古纳市| 莫力| 凤台县| 昂仁县| 沁源县| 霍林郭勒市| 玉林市| 山西省| 河北区| 娄烦县| 偏关县|