當我打電話PHP服務器,服務器使用JSON數據對象迴應我,我需要導航如果狀態爲真,則轉到頁面。
login(){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
let alert = this.alert.create({
title: 'Warning',
subTitle: 'Wrong Username or Password! Please Try Again !',
buttons: ['OK']
});
let loader = this.loading.create({
content: "Checking ! Please wait...",
duration: 1000
});
let email = this.data.email;
let password = this.data.password;
let data = JSON.stringify({email, password});
let link = "http://"link"";
this.http.post(link, data, {headers: headers})
.subscribe(res => {
this.navCtrl.setRoot(Page1);
loader.present();
console.log(res.json());
}, (err) => {
console.log(err);
alert.present();
});
}}