AngularJS $location.path Doesn't Work On Parse Promise
Solution 1:
Because $location
is tightly tied to Angular digest cycles, as well as many other Angular built-in services, all that $location.path
does is updating internal $$path property. It will be used to update the path during the next digest.
And because $http
is tied to digests as well, it triggers the digest when the promise is being resolved or rejected. Generally there's no need to worry to trigger the digest manually, $location will update the location during the next digest. The other answer in the cited question states this unambiguously.
Since the promise wasn't provided by built-in service but by Parse
, the digest needs to be triggered manually, this way Angular 'knows' that the location was updated. Consider
$location.path('/');
$rootScope.$apply();
syntax instead if it pleases you more.
It is possible to set up a watcher to investigate when the digest hits and what happens with location path at that moment
$rootScope.$watch(function () {
console.log('digest! and the path is ' + $location.$$path);
});
Post a Comment for "AngularJS $location.path Doesn't Work On Parse Promise"