From: Dobrica Pavlinusic Date: Fri, 14 Dec 2012 10:25:23 +0000 (+0100) Subject: resource triggers watch before loading X-Git-Tag: 0.4~89 X-Git-Url: http://git.rot13.org/?p=angular-drzb;a=commitdiff_plain;h=0ad8680f58c81f0a821207c0a501ee51641332e5 resource triggers watch before loading --- diff --git a/app/js/controllers.js b/app/js/controllers.js index 4187b9a..984d546 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -36,9 +36,9 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ }); } else { $scope.registration = new Registration({ user: {} }); - $log.info("new Registration", $scope.user); $scope.user = $scope.registration.user; $scope.work = $scope.registration.work; + $log.info("new Registration", $scope.registration); } $log.info( $routeParams.registrationId ); @@ -47,6 +47,12 @@ function RegistrationCtrl($scope, $log, Registration, $routeParams, $location, $ $scope.$watch('user.registration_type', function( oldValue, newValue ) { $log.info("registration_type watch", oldValue, newValue ); + if ( oldValue === newValue ) return; // triggers on resource, so ignore it + if ( ! $scope.user ) { // resource triggers watch before loading json + $log.error("no user in scope"); + return; + } + if ( $scope.user.registration_type == 'lecture' || $scope.user.registration_type == 'poster' ||