Skip to content

Commit

Permalink
fix(sample): prevent direct URL access to a day disabled in the datep…
Browse files Browse the repository at this point in the history
…icker

Redirection from `booking.day` to `booking` if the date has no reservation.

Closes: #17
  • Loading branch information
ncuillery committed Jun 3, 2014
1 parent c3dea30 commit 9523691
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sample/controllers/booking_day.js
@@ -1,7 +1,11 @@
angular.module('ncy-sample')
.controller('BookingDayCtrl', function($scope, $rootScope, $stateParams, rooms) {
.controller('BookingDayCtrl', function($scope, $rootScope, $state, $stateParams, rooms) {
$rootScope.reservationDate = new Date($stateParams.year, $stateParams.month - 1, $stateParams.day);

if(!$scope.between($rootScope.reservationDate).length) {
$state.go('^');
}

$scope.getRoom = function(id) {
return _.findWhere(rooms, {roomId: parseInt(id)});
}
Expand Down

0 comments on commit 9523691

Please sign in to comment.