pass data to sidemenu Ionic
up vote
0
down vote
favorite
I have a login with fb, and upon confirming, redirects to the main page, however I would like to pass the data to the App.html, because my sideMenu is in it. But I can not find way to pass data to app.component.ts
Can anyone give me an idea of how I get data for the side menu?
angular cordova ionic-framework
add a comment |
up vote
0
down vote
favorite
I have a login with fb, and upon confirming, redirects to the main page, however I would like to pass the data to the App.html, because my sideMenu is in it. But I can not find way to pass data to app.component.ts
Can anyone give me an idea of how I get data for the side menu?
angular cordova ionic-framework
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a login with fb, and upon confirming, redirects to the main page, however I would like to pass the data to the App.html, because my sideMenu is in it. But I can not find way to pass data to app.component.ts
Can anyone give me an idea of how I get data for the side menu?
angular cordova ionic-framework
I have a login with fb, and upon confirming, redirects to the main page, however I would like to pass the data to the App.html, because my sideMenu is in it. But I can not find way to pass data to app.component.ts
Can anyone give me an idea of how I get data for the side menu?
angular cordova ionic-framework
angular cordova ionic-framework
edited Nov 10 at 18:23
georgeawg
31.9k104863
31.9k104863
asked Nov 10 at 14:23
Felipe XST
55
55
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12
add a comment |
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
Use the events plugin by ionic
in your app.component.ts
file either create a function or put the code below inside the platform ready to listen for any published events
events.subscribe('user:created', (user, time) => {
// user and time are the same arguments passed in `events.publish(user, time)`
console.log('Welcome', user, 'at', time);
});
in your login.ts
file after successfully login publish data using the code below
this.events.publish('user:created', user, Date.now());
for more info please read the events plugin
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed inevents.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User
– Felipe XST
2 days ago
so you declare global variable in yourapp.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}
– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
|
show 1 more comment
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
Use the events plugin by ionic
in your app.component.ts
file either create a function or put the code below inside the platform ready to listen for any published events
events.subscribe('user:created', (user, time) => {
// user and time are the same arguments passed in `events.publish(user, time)`
console.log('Welcome', user, 'at', time);
});
in your login.ts
file after successfully login publish data using the code below
this.events.publish('user:created', user, Date.now());
for more info please read the events plugin
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed inevents.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User
– Felipe XST
2 days ago
so you declare global variable in yourapp.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}
– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
|
show 1 more comment
up vote
0
down vote
accepted
Use the events plugin by ionic
in your app.component.ts
file either create a function or put the code below inside the platform ready to listen for any published events
events.subscribe('user:created', (user, time) => {
// user and time are the same arguments passed in `events.publish(user, time)`
console.log('Welcome', user, 'at', time);
});
in your login.ts
file after successfully login publish data using the code below
this.events.publish('user:created', user, Date.now());
for more info please read the events plugin
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed inevents.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User
– Felipe XST
2 days ago
so you declare global variable in yourapp.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}
– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
|
show 1 more comment
up vote
0
down vote
accepted
up vote
0
down vote
accepted
Use the events plugin by ionic
in your app.component.ts
file either create a function or put the code below inside the platform ready to listen for any published events
events.subscribe('user:created', (user, time) => {
// user and time are the same arguments passed in `events.publish(user, time)`
console.log('Welcome', user, 'at', time);
});
in your login.ts
file after successfully login publish data using the code below
this.events.publish('user:created', user, Date.now());
for more info please read the events plugin
Use the events plugin by ionic
in your app.component.ts
file either create a function or put the code below inside the platform ready to listen for any published events
events.subscribe('user:created', (user, time) => {
// user and time are the same arguments passed in `events.publish(user, time)`
console.log('Welcome', user, 'at', time);
});
in your login.ts
file after successfully login publish data using the code below
this.events.publish('user:created', user, Date.now());
for more info please read the events plugin
answered Nov 10 at 15:00
nyx97
1118
1118
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed inevents.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User
– Felipe XST
2 days ago
so you declare global variable in yourapp.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}
– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
|
show 1 more comment
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed inevents.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User
– Felipe XST
2 days ago
so you declare global variable in yourapp.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}
– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
Thanks for replying, I believe I have succeeded, but I do not know how to receive the username in the html. but in console.log I was able to see the data being passed.
– Felipe XST
Nov 10 at 16:09
can you show me snippet of your code?
– nyx97
2 days ago
can you show me snippet of your code?
– nyx97
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed in
events.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User– Felipe XST
2 days ago
app.component.ts: this.createUser(events); createUser(events) { events.subscribe('user:created', (user, time) => { // user and time are the same arguments passed in
events.publish(user, time)
console.log('Welcome', user, 'at', time); console.log(user); }); } in my console I see that I received the value of User– Felipe XST
2 days ago
so you declare global variable in your
app.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}– nyx97
2 days ago
so you declare global variable in your
app.component.ts
variable:any; events.subscribe('user:created',(user,time)=>{ this.variable = user; }); then you can get the user in html by using {{ variable }}– nyx97
2 days ago
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
Thanks, I get almost everything, but in html when I insert {{user}} it returns in html [Object, Object]
– Felipe XST
yesterday
|
show 1 more comment
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53239885%2fpass-data-to-sidemenu-ionic%23new-answer', 'question_page');
}
);
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You need to have a shared provider (service) that app, any page or component can import/inject and access n xchange data. See angular.io docs for component interaction using shared service
– Sergey Rudenko
Nov 10 at 20:11
See in this issue: stackoverflow.com/q/53200559/4005366
– Sergey Rudenko
Nov 10 at 20:12