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 year8 month 15 days ago)

No Comments Posted Yet (Be The First To Comment On This)

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