【问题标题】:Cannot read property of undefined in angular 6无法读取角度 6 中未定义的属性
【发布时间】:2018-09-27 21:54:15
【问题描述】:

我无法读取角度 6 中未定义的属性,但它的值显示在模板中。这是我的代码

  this.data.post_data('dashboard/gettodaydata','',true)
               .subscribe((data:any) => {
                 this.today_datas =data.data;
              });

这是我的模板文件

<span class="counter text-danger">{{ today_datas.total_cpc | number }}</span>

【问题讨论】:

    标签: angular angular6


    【解决方案1】:

    绑定试图在today_datas 从 API 调用中填充之前进行评估。使用navigation/elvis运算符

    {{ today_datas?.total_cpc | number }}
    

    【讨论】:

      猜你喜欢
      • 2019-02-28
      • 1970-01-01
      • 1970-01-01
      • 2015-08-10
      • 2019-04-28
      • 2021-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多