load old registration if it exists
[angular-drzb] / app / js / controllers.js
index 9571d98..122746a 100644 (file)
@@ -3,21 +3,28 @@
 /* Controllers */
 
 
-function RegistrationCtrl($scope, $log, Registration) {
-       $scope.master = {};
+function RegistrationCtrl($scope, $log, Registration, $routeParams) {
+
+       $scope.$routeParams = $routeParams;
 
        $scope.update = function(user) {
-               $scope.master = angular.copy(user);
                $log.info("saved", user, user.$save());
        }
 
        $scope.reset = function() {
-               //$scope.user = angular.copy($scope.master);
-               $scope.user = new Registration();
+               if ( $routeParams.registrationId ) {
+                       $scope.user = new Registration();
+                       $scope.user.$get({ registrationId: $routeParams.registrationId });
+                       $log.info("get Registration", $scope.user);
+               } else {
+                       $scope.user = new Registration();
+                       $log.info("new Registration", $scope.user);
+               }
+               
+               $log.info( $routeParams.registrationId );
        }
 
        $scope.reset();
-
 }
 //RegistrationCtrl.$inject = [ '$scope', '$log' ];