Progress event in cordovaFile

I managed to use the $cordovaFile plugin in ngCordova , my only problem is with the function:

   $cordovaFile
                            .downloadFile(source, filePath, true)
                            .then(function (result) {
                                // Success!
                              
                            }, function (err) {
                                
                            }, function (progress) {
                                // constant progress update
                              
                            });

How do i get the percentage of the progress from the progress object ? The documentation doesn’t say anything about it and printing to the console returns an [object Object ]

use JSON.stringify to read the object like

alert(JSON.stringify(progress));

you can get percentage with

progress.loaded*100/progress.total;

1 Like

Yes that solved it ! thanks mate