Angular 5 - Stop errors from undefined object before loading data

后端 未结 4 1047
旧时难觅i
旧时难觅i 2021-02-15 13:57

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:          


        
4条回答
  •  失恋的感觉
    2021-02-15 14:10

    As mentioned in previous responses you can use {{ name | async }} but remember if you want to use {{ name | async }}, name must be a promise or an observable.
    Otherwise you'll get an error like this :

    ERROR Error: InvalidPipeArgument: 'xxx' for pipe 'AsyncPipe'
    

提交回复
热议问题