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 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化