I am new to Angular js 2.0. Currently I am working with a web application which is mainly intended for students. It has social media login for authorization. For that I have used angular2-social-login package. It works perfectly fine.
I have two pages 1) Home page 2)User-dashboard page.When I click on the sign-in button in the home page, the page will route to user-dashboard page. please see the code below (header.component.ts)
if((data.status == 1) && (data.redirect_url == 'dashboard')){
this.router.navigate(['/dashboard']);
}
Now the code in app.route.ts
export const routes:Routes = [
{ path:'dashboard',component:UserDashboardComponent,canActivate: [AuthGuard] },
]
When the user clicks on the sign-in button on the Home page, the page route to User-dashboard page. The user-dashboard page need to display some details of the student includes name, profile pic, address etc. For this I have called a function in ngOnInit() of user-dashboard.component.ts. please see the code below
this.appService.getDashboardDatas(formdata)
.subscribe( (data) => {
this.dashboardData = data;
console.log(this.dashboardData);
return this.dashboardData;}
This code works fine, but the problem is that the data didnt receive on the view page(user-dashboard.component.html). When I console the dashboardData, I can see all the datas that I needed, But not binded to view page. If I refresh the page, I can see all datas in view page. I think the issue is that before loading the data view page is binded. How can I resolve this issue?