AngularJS Essentials
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 4<br />
$scope.parkCar = function (car) {<br />
$http.post("/cars", car)<br />
.success(function (data, status, headers, config) {<br />
retrieveCars();<br />
$scope.message = "The car was parked successfully!";<br />
})<br />
.error(function (data, status, headers, config) {<br />
switch(status) {<br />
case 401: {<br />
$scope.message = "You must be authenticated!"<br />
break;<br />
}<br />
case 500: {<br />
$scope.message = "Something went wrong!";<br />
break;<br />
}<br />
}<br />
console.log(data, status);<br />
});<br />
};<br />
$scope.calculateTicket = function (car) {<br />
$scope.ticket = parkingService.calculateTicket(car);<br />
};<br />
var retrieveCars = function () {<br />
$http.get("/cars")<br />
.success(function(data, status, headers, config) {<br />
$scope.cars = data;<br />
})<br />
.error(function(data, status, headers, config) {<br />
switch(status) {<br />
case 401: {<br />
$scope.message = "You must be authenticated!"<br />
break;<br />
}<br />
case 500: {<br />
$scope.message = "Something went wrong!";<br />
break;<br />
}<br />
}<br />
console.log(data, status);<br />
[ 81 ]<br />
www.it-ebooks.info