Yes i would like to render the returned dat on the searchPage.
I already send you the authservice.ts.
Then i call the Auth Service on app.module.ts
providers: [
StatusBar,
SplashScreen,Camera,AuthService,SplitPane,Common,
{provide: ErrorHandler, useClass: IonicErrorHandler},
AuthserviceProvider
]
})
export class AppModule {}
And then i call it on home.ts to return the UserData
The whole home.ts file
import { Component, ViewChild } from "@angular/core";
import { NavController, Platform, App, MenuController, AlertController } from "ionic-angular";
import { AuthService } from "../../providers/auth-service";
import { Common } from "../../providers/common";
import { Camera, CameraOptions } from "@ionic-native/camera";
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { Http, Headers } from '@angular/http';
import { UploadPage } from '../upload/upload';
import { SearchPage } from '../search/search';
import { UserPage } from '../userProfile/userProfile';
import { MediaPage } from '../mediaProfile/mediaProfile';
@Component({ selector: "page-home", templateUrl: "home.html" })
export class HomePage {
data: any = {};
@ViewChild("updatebox") updatebox;
public userDetails: any;
public resposeData: any;
public dataSet: any;
public noRecords: boolean;
rootPage: any = HomePage;
pages: Array<{ title: string, component: any }>;
userPostData = {
uid: "",
token: "",
username: "",
bio: "",
profile_pic:"",
message: "",
msg_id: "",
title: "",
description: "",
media_pic: "",
created: "",
uid_fk:""
};
constructor(
public common: Common,
public navCtrl: NavController,
public app: App,
public menu: MenuController,
public authService: AuthService,
platform: Platform,
statusBar: StatusBar,
splashScreen: SplashScreen
) {
const data = JSON.parse(localStorage.getItem("userData"));
this.userDetails = data.userData;
this.userPostData.uid = this.userDetails.uid;
this.userPostData.token = this.userDetails.token;
this.userPostData.username = this.userDetails.username;
this.userPostData.msg_id = this.userDetails.msg_id;
this.userPostData.message = this.userDetails.message;
this.userPostData.title = this.userDetails.title;
this.userPostData.description = this.userDetails.description;
this.userPostData.media_pic = this.userDetails.media_pic;
this.userPostData.created = this.userDetails.created;
this.userPostData.profile_pic = this.userDetails.profile_pic;
this.userPostData.bio = this.userDetails.bio;
this.noRecords = false
this.allArtists();
}
UploadPage() {
this.navCtrl.push(UploadPage);
}
SearchPage() {
this.navCtrl.push(SearchPage);
}
HomePage() {
this.navCtrl.push(HomePage);
}
allArtists() {
this.common.presentLoading();
this.authService.postData(this.userPostData, "newsFeed").then(
result => {
this.resposeData = result;
if (this.resposeData.friendsNewsFeed) {
this.common.closeLoading();
this.dataSet = this.resposeData.friendsNewsFeed;
console.log(this.dataSet);
} else {
console.log("No access");
}
},
err => {
//Connection failed message
}
);
}
UserPage(uid_fk, username, bio, profile_pic) {
this.navCtrl.push(UserPage, { uid_fk: uid_fk, username: username, bio: bio, profile_pic: profile_pic });
}
MediaPage(msg_id, message, title, description, media_pic) {
this.navCtrl.push(MediaPage, { msg_id: msg_id, message: message, title: title, description: description, media_pic: media_pic });
}
converTime(time) {
let a = new Date(time * 1000);
return a;
}
backToWelcome() {
const root = this.app.getRootNav();
root.popToRoot();
}
logout() {
//Api Token Logout
localStorage.clear();
setTimeout(() => this.backToWelcome(), 1000);
}
}
thats all the script i use