From 0ad8680f58c81f0a821207c0a501ee51641332e5 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Fri, 14 Dec 2012 11:25:23 +0100 Subject: [PATCH] resource triggers watch before loading --- app/js/controllers.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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' || -- 2.20.1