I have a controller, with a route like this:
#/articles/1234
I want to change the route without completely reloading the controller, so I can keep the positi
You can do this without the $locationChange~
and HistoryState
hacks using route
s resolve promise option.
Assuming you had an article
route where that number is what changed you could do this;
$routeProvider.when(
'/article/:number',
{
templateUrl : 'partial.html',
controller : 'ArticleCtrl',
resolve : {
load : ['$q', '$routeParams', function($q, $routeParams) {
var defer = $q.defer();
//number was specified in the previous route parameters, means we were already on the article page
if ($routeParams.number)
//so dont reload the view
defer.reject('');
//otherwise, the number argument was missing, we came to this location from another route, load the view
else
defer.resolve();
return defer.promise;
}]
}
}
);