API를 사용하여 내 loginpage에서 데이터를 검색했습니다. 이제 해당 데이터에 액세스하려고합니다. tabspage는 로그인 성공 후 열리는 페이지이므로 탭 페이지의 데이터에 액세스 할 수 있습니다. 홈페이지, 프로필 페이지 등 다른 페이지에서 해당 데이터에 액세스 할 수 없습니다.내 탭 페이지의 데이터에는 액세스 할 수 있지만 내 응용 프로그램의 내 홈페이지에는 액세스 할 수 없습니다.
tabspage 또는 loginpage에서 내 데이터에 액세스 할 수있는 몇 가지 코드 또는 개념을 알려주십시오. loginPage
var headers = new Headers();
//headers.append('Content-Type', 'application/x-www-form-urlencoded');
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let options = new RequestOptions({headers: headers});
let postParams ='&password='+ this.loginpass + '&phone=' + this.loginmob;
// console.log(JSON.stringify(postParams));
this.http.post("http://www.btedge.appexperts.net/Ionic_Webservices/login.php", JSON.stringify(postParams), options)
.map(
(res:Response) => { return console.log(this.users=res.json());})
.subscribe(data => {
if(this.users.success=="1")
{
this.loadingCtrl.create({
content: 'Login Successfully... ',
duration: 4000,
dismissOnPageChange: true
}).present();
//alert(this.users.user_id);
this.navCtrl.push(TabsPage,{user_id: this.users.user_id,distributor_id: this.users.distributor_id,user_name:this.users.user_name,user_email:this.users.user_email,user_phoneno:this.users.user_phoneno,user_address:this.users.user_address,distributor_name:this.users.distributor_name,distributor_phoneno:this.users.distributor_phoneno,distributor_address:this.users.distributor_address,distributor_email:this.users.distributor_email});
}
else if(this.users.success=="2")
{
alert("Phone no or Password Incorrect");
//this.navCtrl.push(HomePage);
}
else if(this.users.success=="0")
{
alert("Required Fields Blank..");
//this.navCtrl.push(HomePage);
}
},
error=>{console.log(error)});
TabsPage- 여기에
은 내가 더 전화를 액세스 할 수 없습니다 나는이 페이지에 아무 로그인 페이지
import { Component } from '@angular/core';
import { AppModule } from '../../app/app.module';
import { AlertController,LoadingController } from 'ionic-angular';
import { NavController, NavParams } from 'ionic-angular';
import { AboutPage } from '../about/about';
import { ProfilePage } from '../profile/profile';
import { LoginPage } from '../Login/Login';
import { HomePage } from '../home/home';
import { MsgPage } from "../message/message";
@Component({
selector: 'page-tabs',
templateUrl: 'tabs.html'
})
export class TabsPage {
users: any;
tab1Root = HomePage;
tab2Root = MsgPage;
tab3Root = AboutPage;
tab4Root = ProfilePage;
userphone: any;
constructor(public navCtrl: NavController,private navParams : NavParams) {
this.userphone=this.navParams.get('user_phoneno');
console.log(this.userphone);
}
}
HomePage-에서 오는 전화에 액세스 할 수있게되었습니다. 내가 여기서 뭘해야하지?
import { Component } from '@angular/core';
import { AppModule } from '../../app/app.module';
import { AlertController,LoadingController } from 'ionic-angular';
import { NavController, NavParams } from 'ionic-angular';
import { AboutPage } from '../about/about';
import { ProfilePage } from '../profile/profile';
import { LoginPage } from '../Login/Login';
import { TabsPage } from "../tabs/tabs";
@Component({
selector: 'page-home',
templateUrl: 'home.html',
})
export class HomePage {
userphone: String;
useremail: String;
constructor(public navCtrl: NavController, private navParams : NavParams) {
this.userphone=this.navParams.get('user_phoneno');
console.log(this.userphone);
}
}
답변을 제외하고, 앱에서 데이터를 사용할 수있게하려면 이벤트를 조사하고 싶을 수도 있습니다. https://ionicframework.com/docs/api/util/Events/ – Alex