dou47278 2016-10-15 10:11
浏览 34
已采纳

Ionic:无法从$ http post方法获取不同的数据

I am new to ionic1 framework and working on sidemenu ionic app. Currently i am working on login functionality using web-service, its working fine. I am saving login information using sessionStorage.

sessionStorage.setItem('loggedin_id', data.uid);

after that redirect to profile page using $state.go('app.profile', {}, { reload: true });. In profile controller fetching information on the basis of loggedin_id using $http.post method.

At first time i am getting logged in user's detail on profile page, when i logout using sessionStorage.clear(); it redirect back to login page and than i am logged in again with another user and redirected to profile page it will not display current logged in user's detail it display old user's detail.

I have tried to alert loggedin_id within login function it alert's correct id of users but not user's information. Please help me how to resolve this.

  • 写回答

1条回答 默认 最新

  • douchendan0040 2016-10-15 11:19
    关注

    I have resolve this by using loggedin_id as $stateParams in profile route. Redirect after login like

    $state.go('app.profile', {userID:sessionStorage.getItem('loggedin_id')},{location: "replace", reload: true});
    

    At profile controller post userID as parameter of API. Now i am able to get proper information of logged in user.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制