In my application I have one component sending a user object to another component and it receives it correctly as proven by successful console.log(user.vendorname) returning as expected but it won't show up on the html. The html file
<div class="col-centered">
<h1 *ngIf="user | async">Welcome {{user.vendorname}}</h1>
</div>
The component file
import { User } from '../User';
import { AccountInfo } from './../AccountInfo';
import { LoginService } from './../login.service';
import { Component, OnInit, AfterViewInit, OnDestroy } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import { Subscription } from 'rxjs/Subscription';
import 'rxjs/add/operator/map';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
user: User;
subscription: Subscription;
constructor(route: ActivatedRoute, private loginService: LoginService) {
}
ngOnInit() {
this.subscription = this.loginService.getMessage().subscribe(data => {
this.user = data;
console.log(this.user.vendorname);
});
}
AfterViewInit(){
}
ngOnDestroy() {
// unsubscribe to ensure no memory leaks
}
}