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:
Multiple ways: You can use any one suitable to you.
1. Adding ngIf : If name is undefined or null or '' it will not render the element and prevent errors in console. When name gets defined value it will automatically update the view.
*ngIf="name"
2. Adding async pipe : View will update whenever name gets defined. It waits for name to get defined.
{{ name | async }}
3. Adding fallback value : This is simply or condition. If name is undefined or null or '' , you can decide which fallback value to assign .
{{ name || "" }}