Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display a angular variable in my html page

Tags:

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 ?

like image 658
Nepho Avatar asked Jun 11 '13 12:06

Nepho


People also ask

What is Angular tag in HTML?

AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag. AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions.

How do you find the type of a variable in HTML?

The typeof Operator You can use the JavaScript typeof operator to find the type of a JavaScript variable.


1 Answers

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.

like image 192
Narretz Avatar answered Sep 30 '22 18:09

Narretz