我收到 Cannot read property of undefined in angular 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>
最佳答案
绑定(bind)试图在 today_datas
从 API 调用填充之前进行评估。使用导航
/elvis
操作符
{{ today_datas?.total_cpc | number }}
关于angular - 无法读取 Angular 6 中未定义的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52538673/