Nick
Nick

Reputation: 14273

Angular controller - Unable to display value

This should be a very easy question for most of you guys, but i'm a beginner with angular..

So, i'm trying to display a progressbar (just as a test for the moment) but i'm unable to update the value.

An example can be found here: http://jsbin.com/cuvedoteye/edit?html,output

Here's the controller code:

.controller('test', ['$scope', function ($scope) {
        $scope.progress = function () {
            var display = 100 * (Date.now() % 60) / 60;
            return display;
        }
    }])

and here's the html:

<h3>ProgressBar</h3>
<progress ng-controller="test" value="progress()"></progress>

why it's not working? thanks for any help

EDIT

Updated code with ng-value instead of value: http://jsbin.com/jujewiboya/edit?html,output

I can see it moving in here, but in on my example i can't, it's just fully blue

Upvotes: 0

Views: 77

Answers (3)

Kovalenko Ivan
Kovalenko Ivan

Reputation: 172

Function progress runs only onсe - when controller created.

Try to use $interval. Here's demo with directive and $interval.

Upvotes: 2

Subash
Subash

Reputation: 7256

You got to change value to ng-value.

<h3>ProgressBar</h3>
<progress ng-controller="test" ng-value="progress()"></progress>

Here is a js-fiddle

Upvotes: 2

Olexandr  Poplavskyi
Olexandr Poplavskyi

Reputation: 353

Try ng-value attribute instead of value in the tag

Upvotes: 1

Related Questions