I have googled a lot for this, but unfortunately i did'nt get anything.
The Context
I have a component where i have two child selector like below.
<div class="wrapper"> <div class="main-panel"> <navbar-cmp></navbar-cmp> <router-outlet></router-outlet> <!--<div *ngIf="!isMap()"> <app-footer></app-footer> </div>--> </div> <div class="sidebar" data-active-color="blue" data-background-color="white"> <!-- <div class="sidebar" data-color="red" data-image=""> --> <sidebar-cmp></sidebar-cmp> <!--<div class="sidebar-background" style="background-image: url(assets/img/sidebar-1.jpg)"></div>--> </div> </div>
So according to this nav-bar component will be called and nav-bar contain a promise which take some time. But my flow go to side-bar component before complete the promise in nav-bar component. But i want that control should not go to side-bar component until it clear the promise in nav-bar component.
try this :
@Component({
selector: 'navbar-cmp',
templateUrl: './navbar-cmp.html',
})
export class NavBarComponent implements OnInit {
promiseIsCompleted :boolean = false;
constructor(private signUpService: SignUpService) {
}
ngOnInit() {
youPromise.then(()=>{
this.promiseIsCompleted = true;
})
}
html :
<div class="wrapper">
<div class="main-panel">
<navbar-cmp #navbar ></navbar-cmp>
<router-outlet></router-outlet>
<!--<div *ngIf="!isMap()">
<app-footer></app-footer>
</div>-->
</div>
<div class="sidebar" data-active-color="blue" data-background-color="white">
<!-- <div class="sidebar" data-color="red" data-image=""> -->
<sidebar-cmp *ngIf="navbar.promiseIsCompleted"></sidebar-cmp>
<!--<div class="sidebar-background" style="background-image: url(assets/img/sidebar-1.jpg)"></div>-->
</div>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.