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.

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

报告相同问题?