AngularJS - ReferenceError: "someScopeVar" is not defined
<p>I am building a feedback-form with AngularJS, where the user data is stored in <code>$scope.feedback</code>. Now I want to include a progress bar and need to determine the percentage.</p>

<pre><code>    // $scope-variable to hold the data.
    $scope.feedback = {
        title : undefined,
        name : undefined,
        email : undefined,
        tel : undefined
    };

    // Get the total amount of attributes of $scope.feedback
    var totalAmountOfAttributesOfFeedback = 0;
    for (var k in $scope.feedback) {
        if ($scope.feedback.hasOwnProperty(k)) {
            ++totalAmountOfAttributesOfFeedback;
        }
    }

    // Get the amount of defined attributes of $scope.feedback
    // to determine the percentage of Progress
    $scope.determinePercentageOfAttributesDefined = function () {
        var amountOfDefinedAttributesOfFeedback = 0;
        for (var l in $scope.feedback) {
            if (angular.isDefined($scope.feedback[l])) {
                ++amountOfDefinedAttributesOfFeedback;
            }
        }
        $scope.percentageOfAttributesDefined = (amountOfDefinedAttributesOfFeedback / totalAmountOfAttributesOfFeedback)*100;
        console.log(percentageOfAttributesDefined);
    };
</code></pre>

<p>To calculate the percentage, I am counting the total amount of attributes of <code>$scope.feedback</code>.
To count the amount of attributes already filled by the user, there is the function <code>determinePercentageOfAttributesDefined</code>, which is called whenever an input field is touched.</p>

<p>The problem is, that the variable <code>$scope.percentageOfAttributesDefined</code> is not defined and I get the following error in the browser console:</p>

<pre><code>ReferenceError: percentageOfAttributesDefined is not defined
</code></pre>

<p>I also tried creating the variable somewhere else in my controller, but get the same error. Does somebody know the reason for that?
Other Scope-Variables such as <code>$scope.feedback</code> can be accessed without a problem.</p>

<p>Thanks for taking the time :)</p>