2017-08-05 13 views
2

私はイオンフレームワークを初めて使用しています。ここでは、私の新しいページにホームページから受け取ったパラメータを表示しようとしています。私は次のコードを試しました。しかし、現時点では何も表示されません。誰かが私に何が欠けているか教えてもらえますか?tsファイルで受け取ったパラメータをhtmlページに表示する方法

ありがとうございます。

about.ts

<ion-content padding> 
    <p>This is About Us Page.</p> 
    <ion-card *ngIf="userProfile"> 
     <img [src]="userProfile.photoURL"/> 
     <ion-card-content> 
      <ion-card-title> 
       {{ userProfile.displayName }} 
      </ion-card-title> 
      <p> 
       The UID for this new user is {{userProfile.uid}} and the email is {{userProfile.email}} 
      </p> 
     </ion-card-content> 
    </ion-card> 

</ion-content> 
+0

'navParams'のコードはどのように見えますか?あなたはあなたが期待しているオブジェクトを返すと確信していますか? – Claies

+0

@Claiesはい私はこのような "{" uid ":" 121221 "、" displayName ":" Test User "、" photoURL ":" https://scontent.xx.fbcdn.net/v/t1 " .0-1/s100x100/13891932_1288454467839950_3149500025504162596_n.jpg? –

+0

私は間違いを理解しています。このデータにJSON.parseを実行する必要があります –

答えて

2

チェックこのabout.html

export class AboutPage { 
    userProfile: any = null; 
    constructor(public navCtrl: NavController, public navParams: NavParams) { 
     this.userProfile = navParams.get("userProfile"); 
    } 

    ionViewDidLoad() { 
     console.log('ionViewDidLoad AboutPage'); 
    } 
    goBack() { 
     this.navCtrl.pop(); 
    } 
} 

:それはUSERPROFILEを更新するために、サブスクリプションを使用する必要はありませんhttps://ionicframework.com/docs/api/util/Events/

。これは、login()、loadProfile()などのイベントがトリガされたときに役立ちます。これは、対応するタスクをトリガーするので、関数this.userProfile = navParams.get("userProfile");またはその他の関連するタスクを含めることができます。

関連する問題