Binding 'this' in Angular Material Autocomplete displayWith using Angular 5

前端 未结 5 755
借酒劲吻你
借酒劲吻你 2021-01-04 10:50

I was trying to use the Material Angular autocomplete and I came across the displayWith function which can be apparently used to be the output that is displayed on selection

5条回答
  •  悲&欢浪女
    2021-01-04 11:20

    You just missed an undefined check before using attribute.

    
    
    
        {{ user.first_name }} {{ user.last_name }}
    
    
    displayFn(user) {
        if (!user) return '';
        return user.name;
    }   
    

提交回复
热议问题