Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49103

Show login data on another page

$
0
0

@khalilben wrote:

Hello,

In my login page i have this code

 connexion(){
  var headers = new Headers();
  headers.append('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');

  var params = 'email='+this.userData.email+'&passe='+this.userData.passe;
  this.http.post(apiUrl, params , {headers: headers})
  .subscribe(
    data => {
      this.responseData = data,
      //console.log(this.responseData),
      localStorage.setItem('userData', JSON.stringify(this.responseData));
      this.navCtrl.push('ProfilPage');
    },
    err => {
      console.log(err);
    },
    () => console.log('Call Complete')
  );

}

What i want to do, is once login success, it push me to Profil Page and show informations.
The problem is that my code supposed to do that doesn’t work

 userPostData = {"user_id":"","token":""};
  constructor(public navCtrl: NavController, public navParams: NavParams, public authService:AuthServiceProvider, public app: App) {
    const data = JSON.parse(localStorage.getItem('userData'));
    this.userDetails = data.userData;

    this.userPostData.user_id = this.userDetails.id;
    this.userPostData.token = this.userDetails.remember_token;
  }

And the HTML Part

  <h2>Welcome to {{userDetails.first_name}} {{userDetails.last_name}}</h2>
  <h3>Email: {{userDetails.email}}</h3>

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49103

Trending Articles