23

as the title says I'm trying to display an Angular variable in a html page. I have this function inside the controller I'm using :

$http.get('/api/tasks/?format=json').success(function(data) {
        $scope.tasks = data;
        for (var i=0; i < $scope.tasks.results.length; i++)
        {
            if ($scope.tasks.results.status == 0)
            {
                tobedone++;
            }
        }
    });

And now I'd like to display tobedone inside my html page. I've tried [[tobedone]] (I'm using Django, thus custom providers), but nothing displays. Any help please ?

1 Answer 1

48

In your template, you have access to all the variables that are members of the current $scope. So, tobedone should be $scope.tobedone, and then you can display it with {{tobedone}}, or [[tobedone]] in your case.

Sign up to request clarification or add additional context in comments.

2 Comments

Try it and you will see :)
It is legal Angular expects an expression which can contain literals, operators, and variables. Example {{ 5 + 5 }} or {{ firstName + " " + lastName }} @Puce the op knew it works and wanted to know if it is legal or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.