b940e9076e8408f7e9103ce5719ec001a6e103e1
[angular-drzb] / app / js / controllers.js
1 'use strict';
2
3 /* Controllers */
4
5
6 function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $route) {
7
8         $scope.$routeParams = $routeParams;
9         $scope.$location = $location;
10
11         $scope.update = function(user) {
12                 user.$save( function(user) {
13                         $log.info("saved", user);
14                         $log.info('id =', user.id);
15                         if ( user.id ) {
16                                 $location.path( '/registration-finished/' + user.id );
17                         } else {
18                                 $log.error("can't find id in ", user);
19                         }
20                 });
21         }
22
23         $scope.reset = function() {
24                 if ( $routeParams.registrationId ) {
25                         $scope.user = new Registration();
26                         $scope.user.$get({ registrationId: $routeParams.registrationId });
27                         $log.info("get Registration", $scope.user);
28                 } else {
29                         $scope.user = new Registration();
30                         $log.info("new Registration", $scope.user);
31                 }
32                 
33                 $log.info( $routeParams.registrationId );
34         }
35
36         $scope.reset();
37 }
38 //RegistrationCtrl.$inject = [ '$scope', '$log' ];
39
40
41 function MyCtrl2() {
42 }
43 MyCtrl2.$inject = [];