I created an angular module that uses the current $location.path to load content dynamically. I set up the module config like this:
var app = angular.module('App',['ngRoute']).
config(
['$routeProvider','$locationProvider','$sceProvider'],
function($routeProvider,$locationProvider,$sceProvider){
$routeProvider.
otherwise({
templateUrl: 'views/_view.html',
controller: 'ViewCtr',
resolve: {
load: function(dataFactory,$route,$location){
return dataFactory.load($location.path());
}
}
});
$locationProvider.html5Mode(true);
$sceProvider.enabled(false);
});
It works perfectly although when I set $scope.$on('$routeChangeStart') to add some animations when content is loading, it fires the route change twice. I believe it's because I set the routeProider as "otherwise" and it redirects every time.
Can you correct me if I am wrong or tell me if and how it is possible to differentiate from a real route change and a redirect? Thank you.