最初我的app.component.ts文件被加载然后我有两个变量,name并email从API获取调用更新,为了进行此api调用我需要用户名如果我没有用户名我将无法更新此名称和电子邮件.
一旦我获得了用户名,我就可以拨打api电话,但我的用户名只有在登录成功后才可用.
我的app.html有这个,下面的代码是我的sidemenu的一部分
<ion-item class="profile-info">
<ion-icon name="person" item-left></ion-icon>
<h2>{{name}}</h2>
<p class="se-email">{{email}}</p>
</ion-item>
Run Code Online (Sandbox Code Playgroud)
我的app.component.ts文件有这个
name
email
if(localStorage.getItem("username")){
//here it is invoking 2nd time because i have stored the username after login so no problem
this.getUserDetails();//this function call the same api
}else{
//at first thime i am not able update the name and email because i dont have username
//so i am trying to update the name with set and get method where it will return my data …Run Code Online (Sandbox Code Playgroud)