What's the best way to prevent errors in console from objects that are still undefined?
Let's say I have this
name : string;
constructor(private data: DataService) {
this.data.name.subscribe(res => this.name = res);
}
Inside my html I have this
<p> {{name}}</p>
When I load the page I get _co.name is not defined, but the page still shows the value of name. The component is loading before getting the data I suppose.
What's the best approach to prevent this?
I saw ngIf is not null or something like that, is an option. But then I saw something about Resolve.