javascript - How to refresh resolve? -
using ui-router
, have state resolve function:
.state('tab.social', { url: '/social/', views: { 'menucontent': { templateurl: 'templates/social/tab-social.html', controller: 'socialctrl', resolve: { socialauthresolve: socialauthresolve } } } })
i capture resolve in controller follows:
.controller('socialctrl', function($scope, socialauth, socialauthresolve) { // console.log(socialauthresolve); // $scope.logout = function() { socialauth.logout(); $state.go('tab.social', {}, {reload: true}); }; // $scope.login= function() { socialauth.login(); $state.go('tab.social', {}, {reload: true}); }; })
however, when either pressing logout
or login
, state not refreshed. using parameters resolve socialauthresolve
, updated. in case, old parameters still in there.
only when refresh browser, variables , page updated accordingly. how can refresh page after logout
, login
? instance, force resolve again?
here sample state config:
.state('app.statename', { url: "/theurl", views: { 'myviewname': { templateurl: "templates/template.html", controller: 'somecontroller', resolve: { pleaseresolve: function() { console.log("i resolved"); } } } } })
in controller (assuming somecontroller
mentioned above), whenever enter state run this.
var res = ($state.$current.self.views.myviewname.resolve.pleasereslove) res.call()
this call resolve function every time come view.
Comments
Post a Comment