Changing the location

There are many ways to navigate, but we need to identify where our resource is located. In order to navigate within the route mechanism, without refreshing the page, we can use the $location service. There is a function called path that will change the URL after the #, allowing the application to be a single-page one. However, sometimes, it might be necessary to navigate out of the application boundaries. It could be done by the $window service by means of the location.href
property as follows:

controller.js
snippet
parking.controller("carController", function($scope, $routeParams,
$location, $window, parkingHttpFacade, parkingService) {
$scope.depart = function(car) {
parkingHttpFacade.deleteCar(car)
.success(function(data, status) {
$location.path("/parking");
})
.error(function(data, status) {
$window.location.href = "error.html";
});
};
var retrieveCar = function(id) {
parkingHttpFacade.getCar(id)
.success(function(data, status) {
$scope.car = data;
$scope.ticket = parkingService.calculateTicket(car);
})
.error(function(data, status) {
$window.location.href = "error.html";
});
};
retrieveCar($routeParams.id);
});
Related Tutorial