I have a route that can have numerous optional query parameters:
$stateProvider.state("directory.search", { url: '/directory/search?name&email', templateUrl: 'view.html', controller: 'controller' When the user fills the form to search the directory a function in the $scope changes the state causing the controller to reload:
$scope.searchDirectory = function () { $state.go('directory.search', { name: $scope.Model.Query.name, email: $scope.Model.Query.email }, { reload: true }); }; In the controller I have a conditional: if($state.params){return data} dictating whether or not my service will be queried.
This works great except if the user clicks the brower's forward and/or back buttons. In both these cases the state (route) changes the query parameters correctly but does not reload the controller.
From what I've read the controller will be reloaded only if the actual route changes. Is there anyway to make this example work only using query parameters or must I use a changing route?