[Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

在数据请求完成通过 ionViewDidLoad 展示页面的时候

[Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

[Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

报错误 : ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

[Angular] ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'name' of undefined

因为在我们加载对象的时候,用的是异步模式,即使promise立刻被处理返回,但是浏览器在开始加载对象的时候,这个对象还是没有定义,所以也就读不到属性

解决:

<ion-content>
  <ion-list no-lines>
    <ion-item>
      名称
      <span class="fr old-color">{{data?.name}}</span>
    </ion-item>
  </ion-list>
</ion-content>

参考:

https://stackoverflow.com/questions/38078741/angularjs-2-exception-error-uncaught-in-promise-typeerror-cannot-set-prope

http://blog.****.net/Francis123580/article/details/72876541