我使用基於角度4框架的Ionic 3。我需要知道,如果我有多個子組件,我可以一個一個地異步加載它們:角度4:逐個加載組件
- 加載父項;
- 加載第一個孩子;
- 當第一個孩子加載時,加載第二個孩子;
- 當第二子加載,加載第三子
- 等
例如我有孩子一個父組件app.module.ts
:
@NgModule({
declarations: [
AppComponentPage
],
imports: [
IonicPageModule.forChild(AppComponentPage),
ChildOneComponentModule,
ChildTwoComponentModule,
ChildThreeComponentModule,
ChildFourComponentModule,
],
entryComponents: [
AppComponentPage
]})
export class AppComponentPageModule {}
和app.component.ts
:
import { Component } from '@angular/core';
//import all child components
@Component({
selector: 'app-parent-component',
template: `
<child1-component></child1-component>
<child2-component></child2-component>
<child3-component></child3-component>
<child4-component></child4-component>
`
})
export class AppComponentPage {
//HOW TO LOAD?
}
利用setTimeout和ngIf –
你是什麼意思「異步加載組件」?你的意思是「一個接一個地顯示它們,每N秒」?還有別的嗎? –
你想要加載什麼?什麼是「一個接一個」。 「一個接一個」加載時你期望獲得什麼知識? –