1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Angularで、ERROR TypeError: Cannot read property 'city' of undefined

Last updated at Posted at 2018-08-17

概要

前回の【エラー解決】Angularでerror TS1005: ',' expected.のエラーの解決
に引き続き、Angularのエラーについて。

今回はGoogle Chromeのデベロッパーツール(検証モード)でエラーが出たので、その解決方法を書きます。

エラー内容

ERROR TypeError: Cannot read property 'city' of undefined

'city' の中は、人それぞれプロパティ命名が違うことに注意。

AngularStarter.png

このエラーが出た場合は、以下のように解釈すると良い。

プロパティが存在しないため、city プロパティを読み取れません。

つまり、cityプロパティの前の上位のオブジェクトを疑ってみる。

このエラーの場合、Google Chromeのデベロッパーツール(検証モード)上で、(RentalListItemComponent.html:5)とあるので、このファイルの中から、
cityプロパティを探します。

rental-list-item_component_html_—___bwm-project_bwm-ng.png

.(ドット)で繋いでいる、currentRentalが違っていたため、エラーが出ていた。

ここを変更して解決できました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?