Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

How to display login details to next page?

$
0
0

@amirarshad96 wrote:

Hi guys. Im still new in ionic. Im really appreciate to any help from you guys.
I have make a login using username/password from local server api. But i couldnt find how to display the user’s details to the next page.
Here is the details.

Capture1

login.html
<ion-content padding>

<ion-label>Username</ion-label>

<ion-input type=“text” [(ngModel)]=“userData.name” value="" ></ion-input>

<ion-label>Password</ion-label>

<ion-input type=“password” [(ngModel)]=“userData.pass” value="" ></ion-input>

<button ion-button (click)=“signInUser()” >Sign In</button>

</ion-content>

login.ts
import { Component } from ‘@angular/core’;
import { NavController, NavParams } from ‘ionic-angular’;
import { Http } from ‘@angular/http’;
import ‘rxjs/add/operator/map’;
import { Observable } from ‘rxjs/Observable’;
import { ProfilePage } from ‘…/profile/profile’;

@Component({
selector: ‘page-login’,
templateUrl: ‘login.html’,
})

export class LoginPage {

userData = {“name”: “”, “pass”: “”};

result: any= ;
result2 : any = ;
data: Observable;

constructor(public http: Http, public navCtrl: NavController, public navParams: NavParams) {

}

signInUser() {

let postData = {
  "Username": this.userData.name,
  "Password": this.userData.pass
}

this.http.post("http://192.168.1.39/eperumahanapi/api/mobilelogin", postData)
.map(res => res.json())
.subscribe((data:any) => {
  this.result = data.LoginInfo;
  this.result2 = data.LoginStatus;

  if(this.result2.Status === "OK")
  {
  
    console.log("Success");
    this.navCtrl.push(ProfilePage);
  }
  else
  {
    console.log("Error");
  }
       
 }, error => {
  console.log(error);
});

}

}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>