You should run the expression as function in the $apply()
method like
app.run(function ($location, $window, $rootScope) {
$window.addEventListener('message', function(e) {
$rootScope.$apply(function() {
$location.path("/abc");
console.log($location.path());
});
});
});
See documentation – ng.$rootScope.Scope.
If you want to improve testability, use $console
instead of console
and inject that object as well.