How to update a vaiable in component.ts file from another ts file?

<p>Initially my app.component.ts file is loaded then I have two variable names and email which are updated from an API get call, in order to make this api call I need username if I don&#39;t have the username I will be not able to update this name and email.<br /> <br /> I will be able to make the api call once I got the username but my username will be available after the login success only.<br /> <br /> my app.html has this and the below code is a part of my sidemenu<br /> <br /> <ion-item class="profile-info"><br /> <ion-icon item-left="" name="person"></ion-icon></ion-item><br /> &nbsp;</p> <h2>{{name}}</h2> <p>&nbsp; <p class="se-email">{{email}}</p> <br /> <br /> my app.component.ts file has this<br /> <br /> name<br /> email<br /> <br /> if(localStorage.getItem(&quot;username&quot;)){<br /> //here it is invoking 2nd time because i have stored the username after login so no problem<br /> this.getUserDetails();//this function call the same api<br /> }else{<br /> //at first thime i am not able update the name and email because i dont have username<br /> //so i am trying to update the name with set and get method where it will return my data<br /> =this.service.getUserName();<br /> = this.service.getUserEmail();<br /> }</p> <p>&nbsp;</p>

Added By : Rekha (1 year3 month 14 days ago)


In app.component.ts :

import { Events } from 'ionic-angular';
constructor(public events: Events) {
events.subscribe('user:login', () => {

loggedIn() {
console.log("logged in");
in the calling Page:

import { Events } from 'ionic-angular';
constructor(public events: Events) {

logIn() {
Please share your views with us
Check if you want to display your email-id.
Enter the sum of digits
1+5 =