AngularJS Essentials
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 4<br />
<br />
The plate must have at most 10 characters!<br />
<br />
<br />
The plate must start with non-digits, followed by 4 to 7 numbers!<br />
<br />
<br />
Passing parameters<br />
The route mechanism also allows us to pass parameters. In order to obtain the<br />
passed parameter inside the controller, we need to inject the $routeParams service,<br />
which will provide us with the parameters passed through the URL:<br />
controller.js<br />
parking.controller("carController", function ($scope, $routeParams,<br />
parkingHttpFacade, parkingService) {<br />
$scope.depart = function (car) {<br />
parkingHttpFacade.deleteCar(car)<br />
.success(function (data, status) {<br />
$scope.message = "OK";<br />
})<br />
.error(function (data, status) {<br />
$scope.message = "Something went wrong!";<br />
});<br />
};<br />
var retrieveCar = function (id) {<br />
parkingHttpFacade.getCar(id)<br />
.success(function (data, status) {<br />
$scope.car = data;<br />
$scope.ticket = parkingService.calculateTicket(car);<br />
})<br />
.error(function (data, status) {<br />
$scope.message = "Something went wrong!";<br />
});<br />
};<br />
retrieveCar($routeParams.id);<br />
});<br />
car.html<br />
Car Details<br />
Plate<br />
[ 91 ]<br />
www.it-ebooks.info