0

I have a $scope.event where i am pushing data when i received from a server , I am working with the angularjs progress-bar so based on user interaction i want to start recording data so when data start recording i want to create new array like $scope.progressbarData so i can set dynamic value of the progressbar.

ctrl.js

 $scope.event = [];
 $scope.progressbarData = [];
 $scope.dynamic = 0;
    $scope.max = 200;
    socket.on('ditConsumer',function (data) {
        var obj = {
            file:$scope.filename,
            data:data
        }
        $scope.event.push(data);
        if(sendMessageFlag === true) {
            $scope.dynamic = $scope.event.length;
           return  sendMessageToFile(obj);

        }
    });

main.html

<div class="row">
        <div class="col-md-10">
            <uib-progressbar max="max" animate="true" value="dynamic">{{dynamic}} / {{max}}</uib-progressbar>
        </div>
    </div>
3
  • 4
    Add another Array.push()? Unless I'm missing something. Commented Aug 10, 2016 at 16:15
  • I was looking for any other solution , but for now i will go with this approach array.push. Thanks for the answer Commented Aug 10, 2016 at 16:22
  • Any other solution would likely obscure logic from the reader Commented Aug 10, 2016 at 16:23

1 Answer 1

1

You can just add another Array.push() inside your event handler. This is readable and is nothing short of the standard approach in this situation.

$scope.event = [];
 $scope.progressbarData = [];
 $scope.dynamic = 0;
    $scope.max = 200;
    socket.on('ditConsumer',function (data) {
        var obj = {
            file:$scope.filename,
            data:data
        }
        $scope.event.push(data);
        $scope.progressbarData.push(data);
        if(sendMessageFlag === true) {
            $scope.dynamic = $scope.event.length;
           return  sendMessageToFile(obj);

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

1 Comment

Thanks that make sense!

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.