javascript - Force page to refresh after a POST angularjs -
i tried put $ state.reload in controller after post request, not refresh page. therefore, after register form, data not updated on page .. obliged refresh manually shows me right data.
.controller('editctrl', function($scope, $stateparams, $state, appservice) { $scope.infos = appservice.getobject(); console.log($scope.infos); appservice.user($scope.infos).then(function(response){ $scope.user = response; console.log($scope.user); }); $scope.save = function (currobj) { appservice.edituser($scope.form,$scope.infos).then(function(response){ appservice.addobject(currobj); console.log(currobj); $state.reload('menu.infosuser'); $ionicloading.hide(); $state.go('menu.infosuser',{reload: true}); }); }; })
i reply possible proposals :)
if want reload page use location.reload()
reloading page like
.controller('editctrl', function($scope, $stateparams, $state, appservice) { $scope.infos = appservice.getobject(); console.log($scope.infos); appservice.user($scope.infos).then(function(response){ $scope.user = response; console.log($scope.user); }); $scope.save = function (currobj) { appservice.edituser($scope.form,$scope.infos).then(function(response){ appservice.addobject(currobj); console.log(currobj); location.reload(); }); }; })
or can reload state using $state.go('menu.infosuser',{reload: true});
, clear cached data, eg
.controller('editctrl', function($scope, $stateparams, $state, appservice) { $scope.infos = appservice.getobject(); console.log($scope.infos); appservice.user($scope.infos).then(function(response){ $scope.user = response; console.log($scope.user); }); $scope.save = function (currobj) { appservice.edituser($scope.form,$scope.infos).then(function(response){ appservice.addobject(currobj); console.log(currobj); $ionicloading.hide(); $state.go('menu.infosuser',{reload: true}); }); }; })
Comments
Post a Comment