0

index.html http://pastie.org/10777655

app.js http://pastie.org/10777651

I am new to angularjs. Can anybody please solve this problem? Please reload the pastie url if it does not works.

aabiskar
  • 654
  • 9
  • 24
  • You don't need any Angular skill to generate CSV file. Basically your content is in the form of array. Look here for your solution. **http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side** – Arun Shinde Mar 29 '16 at 10:17
  • I need to solve it using angular. Can anyone help me? – aabiskar Mar 29 '16 at 11:47

1 Answers1

1

Looking after ngCsv documentation found errors in your application.

1) ngCsv module has dependency of ngSanitize which you not included.

2) ng-csv="getArray()" Could be an expression, a value or a promise. But in your case i think something wrong.

var app = angular.module('mainApp',['ngSanitize','ngCsv']);

app.controller('myCtrl',function($scope,$http){

var endpoint = 'http://localhost:8080';

$scope.show_table = true;

$scope.ShowSearchTab= true;

$scope.hideTable = function(){
    $scope.show_table = false;
};

$scope.ClickShow = function(){
    $scope.ShowSearchTab = true;
};

$scope.test = [
                {'companyname':'Company 1', 'streetaddress':'Address 1', 'executive':'exe 1', 'webaddress':'www.example1.com', 'dunsno':'xxx', 'leadid':'yyy'},
                {'companyname':'Company 2', 'streetaddress':'Address 2', 'executive':'exe 2', 'webaddress':'www.example2.com', 'dunsno':'xxx', 'leadid':'yyy'},
                {'companyname':'Company 3', 'streetaddress':'Address 3', 'executive':'exe 3', 'webaddress':'www.example3.com', 'dunsno':'xxx', 'leadid':'yyy'},
                {'companyname':'Company 4', 'streetaddress':'Address 4', 'executive':'exe 4', 'webaddress':'www.example4.com', 'dunsno':'xxx', 'leadid':'yyy'}
           ]
  $scope.getArray = function(){
    return $scope.test;
  }

});

Working Plunkr is here https://plnkr.co/edit/K5l3snujJ3GQtPyjRJLZ?p=preview

Arun Shinde
  • 1,185
  • 6
  • 12