0

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

7
  • where did <progress> come from? have you defined a directive somewhere? Commented Jan 26, 2016 at 11:10
  • progress is a html 5 tag: w3schools.com/tags/tag_progress.asp Commented Jan 26, 2016 at 11:13
  • oh ok. i wasn't aware of that tag. Let me try to see whats wrong with your code then. Commented Jan 26, 2016 at 11:15
  • 1
    how is the progress bar meant to work? change value to ng-value. Commented Jan 26, 2016 at 11:20
  • 1
    function progress runs only onсe - when controller created. Try to use $interval. Here's demo with directive and $interval. Commented Jan 26, 2016 at 11:29

3 Answers 3

2

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

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

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

Comments

2

You got to change value to ng-value.

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

Here is a js-fiddle

4 Comments

if i change it to ng-value, i'm not able to see it moving. Why?
Ok. What you are trying to do is not that easily achievable. I would rather use css animation for simulating loading. Is that a option?
yes, i mean, i'm just doing some proof of concept before starting my real project, i thought it would have been this easy, but i can evaluate different options without any problem
the strange thing tho, is that in the second jsbin link in my question, it work as i want, but it does not in my project for some reason that i cannot understand
1

Try ng-value attribute instead of value in the tag

9 Comments

with ng-value i can see something in the value tag, but i actually wanted to see the bar moving...all i have is a full progressbar. Is it something that i have to change in the controller function?
could you please to try define max attr too?
actually, if i add ng-value in the jsbin link above i can see it moving, but on my code it's not moving for some reason..
Also your progress() function call will reset progress on each call.
I think it shouldn`t move at all when value attr is set. If you wish to see moveing, you need increment this value
|

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.