'use strict';

angular.module('ccj16reg.view.registration', ['ngRoute', 'ngMaterial', 'ccj16reg.registration'])

.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/registration/:securityKey', {
		templateUrl: 'views/registration/registration.html',
		controller: 'RegistrationCtrl',
		resolve: {
			'registrationData': function($route, $location, registration) {
				return registration.get({securityKey: $route.current.params.securityKey});
			},
		},
	});
}])

.controller('RegistrationCtrl', function($scope, $routeParams, $window, registrationData) {
	$scope.registration = registrationData;
	$scope.$emit('CurrentGroupInformationChanged', registrationData);
	$scope.printPage = function() {
		$window.print();
	};
});

'use strict';

angular.module('ccj16reg.view.registration', ['ngRoute', 'ngMaterial', 'ccj16reg.registration'])

.config(['$routeProvider', function($routeProvider) {
	$routeProvider.when('/registration/:securityKey', {
		templateUrl: 'views/registration/registration.html',
		controller: 'RegistrationCtrl',
		resolve: {
			'registrationData': function($route, $location, registration) {
				return registration.get({securityKey: $route.current.params.securityKey}).$promise;
			},
		},
	});
}])

.controller('RegistrationCtrl', function($scope, $routeParams, $window, registrationData) {
	$scope.registration = registrationData;
	$scope.$emit('CurrentGroupInformationChanged', registrationData);
	$scope.printPage = function() {
		$window.print();
	};
});

Make sure to return the promise when in a resolve function.
Make sure to return the promise when in a resolve function.

ngResource's returned from resolve will render immediately.  This is of course
broken, as the result may come later.  If the html page takes a similar amount
of time to be fetched as the result, it appears to complete fine.  However,
if the html page returns sooner, then the data won't be present causing
failures later on.
