angularjs - Is it possible to check if the current route change is a redirect rule? -
i created angular module uses current $location.path load content dynamically. set module config 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){ homecoming datafactory.load($location.path()); } } }); $locationprovider.html5mode(true); $sceprovider.enabled(false); });
it works although when set $scope.$on('$routechangestart') add together animations when content loading, fires route alter twice. believe it's because set routeproider "otherwise" , redirects every time.
can right me if wrong or tell me if , how possible differentiate real route alter , redirect? give thanks you.
switch using $routechangesuccess instead of $routechangestart. ng-animate (https://docs.angularjs.org/api/nganimate) able handle improve listening in routechanges.
angularjs routes route-provider
No comments:
Post a Comment