0
私は応答からデータを読み込み、HTMLで設定しようとしています。しかし、私には未定義のエラーが出ています。誰でも私がここで間違っていることを助けることができますか?未定義のプロパティ 'user'を読み取ることができません
後は、コンポーネントの抜粋です:
userProfile: any
constructor(private _userProfileService: UserProfileService){}
ngOnInit(){
this._userProfileService.getProfileData()
.subscribe(data => {
console.log("Response");
console.log(data);
this.userProfile = data;
console.log(this.userProfile.user.firstname);
});
}
HTML:
<h2>{{userProfile.user.firstname}} {{userProfile.user.lastname}}'s Profile <a href="#"><img src="assets/img/pen.png" alt="pen"></a></h2>
使用:USERPROFILE:任意= {}; –
あなたはなぜ私の答えを最初に受け入れていないのですか? –
@VivekDoshiまず、あなたの答えに感謝し、私の問題を解決しました。私は何ミリ秒で答えを投稿したのかを確認しませんでした。そして、このコミュニティが開発者が問題を解決し、 。 –