So, I'm trying to update the path to submit the form with
$location.path('/search');
But it does not start the route registered in '/search' . I also tried with a trailing slash. Nothing, I also tried $scope.$apply , but I just got the error $apply already in progress , so there is definitely a scope.
Why not call the controller registered on the route, or load the templateUrl registered on it.
Router
App.config(function ($routeProvider, $locationProvider) { $locationProvider.html5Mode(true).hashPrefix('!'); $routeProvider .when("/", { "controller" : "HomeController", "templateUrl" : "templates/home.html" }) .when("/search", { "controller" : "SearchResultsController", "templateUrl" : "templates/search-results.html" }) .when("/search/:location", { "controller" : "SearchLocationController", "templateUrl" : "templates/search-results.html" }) .otherwise({ "redirect" : "/" }); });
ng-submit callback
$scope.doSearchRequest = function (event, params) {
change
Adding this
$scope.$on('$routeChangeStart', function(next, current) { $console.log('$routeChangeStart', arguments); });
Just before calling $location.path it is shown that the route does not begin to change. Is this a bug in Angular 1.2.5 ?
source share