'use strict';

angular.module('confRegistrationWebApp')
  .directive('block', function () {
    return {
      templateUrl: 'views/blockDirective.html',
      restrict: 'E',
      controller: function ($scope, AnswerCache, RegistrationCache, uuid) {
        var currentRegistration = RegistrationCache.getCurrentRightNow($scope.conference.id);
        var answerForThisBlock = _.where(currentRegistration.answers, { 'blockId': $scope.block.id });
        if (answerForThisBlock.length > 0) {
          $scope.answer = answerForThisBlock[0];
        }
        if (!angular.isDefined($scope.answer)) {
          $scope.answer = {
            id : uuid(),
            registrationId : currentRegistration.id,
            blockId : $scope.block.id,
            value : {}
          };
          currentRegistration.answers.push($scope.answer);
        }

        AnswerCache.syncBlock($scope, 'answer');
      }
    };
  });

'use strict';

angular.module('confRegistrationWebApp')
  .directive('block', function () {
    return {
      templateUrl: 'views/blockDirective.html',
      restrict: 'E',
      controller: function ($scope, AnswerCache, RegistrationCache, uuid) {
        var currentRegistration = RegistrationCache.getCurrentRightNow($scope.conference.id);
        for (var i = 0;i < currentRegistration.answers.length; i++) {
          if (angular.isDefined(currentRegistration.answers[i]) &&
              currentRegistration.answers[i].blockId === $scope.block.id) {
            $scope.answer = currentRegistration.answers[i];
            break;
          }
        }
        if (!angular.isDefined($scope.answer)) {
          $scope.answer = {
            id : uuid(),
            registrationId : currentRegistration.id,
            blockId : $scope.block.id,
            value : {}
          };
          currentRegistration.answers.push($scope.answer);
        }

        AnswerCache.syncBlock($scope, 'answer');
      }
    };
  });

--- 
+++ 
@@ -7,12 +7,9 @@
       restrict: 'E',
       controller: function ($scope, AnswerCache, RegistrationCache, uuid) {
         var currentRegistration = RegistrationCache.getCurrentRightNow($scope.conference.id);
-        for (var i = 0;i < currentRegistration.answers.length; i++) {
-          if (angular.isDefined(currentRegistration.answers[i]) &&
-              currentRegistration.answers[i].blockId === $scope.block.id) {
-            $scope.answer = currentRegistration.answers[i];
-            break;
-          }
+        var answerForThisBlock = _.where(currentRegistration.answers, { 'blockId': $scope.block.id });
+        if (answerForThisBlock.length > 0) {
+          $scope.answer = answerForThisBlock[0];
         }
         if (!angular.isDefined($scope.answer)) {
           $scope.answer = {
Tidy up for loop code
