0

I am using factory to download the file csv and parse it to array. I am trying using angular-csv-import to parse my string to array. My string looks like:

name,total,table,active ↵דווד,2,1, ↵יוליק גו…, ↵בוריס וטניה ,2,25, ↵גיצה איגור,2,25.....

and my code is:

 DownloadFile.all().then(function (fileArray) {
              $scope.csv = {
                content: fileArray,
                header: true,
                headerVisible: true,
                separator: ',',
                separatorVisible: true,
                result: null,
                encoding: 'ISO-8859-1',
                encodingVisible: true

              };

then I am using:

 $scope.$watch('csv.result', function () {
    if ($scope.csv.result != null) {

I can't see that result is firing.... Maybe there is any other library that will format my string to normal array

4
  • It seems like you are changing your whole csv property but watching csv.result. Try $scope.$watch("csv"), function () { ... Commented Jun 8, 2016 at 11:23
  • result null...maybe I should take only files instance....do we have anther way to parse this if yes please proved working example of my type Commented Jun 8, 2016 at 11:28
  • result will be null because in your code you are assigning it to null, look at it again. you are looking for if ($scope.csv.content != null) Commented Jun 8, 2016 at 11:31
  • you are wrong! please see github.com/bahaaldine/angular-csv-import it should rerun result with array...this code was working by directive as upload the file from locally but when I change it to download from url and then give the result of file to content then getting it null... Commented Jun 8, 2016 at 11:35

0

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.