I have my login controller where i login and on success I get data to be displayed on home page. How do i pass this data to home component?
this is the function in login Component
ngOnInit() {
this.returnUrl = '/home';
}
doLogin(event) {
// console.log(event);
// console.log(this.loginForm.value);
this.authenticationService.login(this.loginForm.value.username, this.loginForm.value.password)
.subscribe(
(response) => {
console.log(response);
if(response.authenticateResult==0){
sessionStorage.setItem('user_token', response.user_token);
console.log(response.project_list.projects);
this.router.navigate([this.returnUrl]);
}else{
this.error = 'Please enter correct Username and password';
}
}
)
}
response.project_list.projects has list of projects which I want to display in home page. I am new to angular 2 . So I am not understanding how i can get access to the data which is in login component. Is there any way to access data from 1 component to other and process it according to that particular component?