bahaaldine / angular-csv-import

Angular component that lets you import and convert CSV file to JSON
MIT License
150 stars 89 forks source link

Error 'call back is not a function' when running with angular 1.5.8 #51

Open kslo88 opened 8 years ago

kslo88 commented 8 years ago

Hi,

Getting below error when running with angular 1.5.8.

Error: scope.callback is not a function .link/</reader.onload/</<@http://192.168.56.101:9000/bower_components/angular-csv-import/dist/angular-csv-import.js:68:8 $RootScopeProvider/this.$get</Scope.prototype.$digest@http://192.168.56.101:9000/bower_components/angular/angular.js:16789:13 $RootScopeProvider/this.$get</Scope.prototype.$apply@http://192.168.56.101:9000/bower_components/angular/angular.js:17003:13 .link/</reader.onload@http://192.168.56.101:9000/bower_components/angular-csv-import/dist/angular-csv-import.js:58:6

http://192.168.56.101:9000/bower_components/angular/angular.js Line 13294

JohnTheBeloved commented 8 years ago

The value has to be a variable and not just a value like so callback="callbackvariable" and not callback="callbackfunction()"

The callback would be a variable in the scope assigned to a function

function callback function(){
   //do stuff here
}

$scope.callbackvariable = callbackfuntion;
JohnTheBeloved commented 8 years ago

Apologies, this doesn't work, it doesn't resolve scope changes

osalama7 commented 8 years ago

Hello, I'm facing the same issue with integration of this component , I'm running the code from the example in main.js file in this repo. The error occurs when I import a file within my node app code, the scope is loaded with results correctly, but the console logs the TypeError: scope.callback is not a function at angular-csv-import: 68 I'm wondering whats wrong with my integration, because I can't fix the entire code of the module.

roberttolton commented 8 years ago

+1 Running angular.js 1.5.8 and getting TypeError: scope.callback is not a function

SarasArya commented 8 years ago

+1 Running angular.js 1.5.8 and getting TypeError : scope.callback is not a function

nainyshah commented 8 years ago

can anybody resolve this error

csacanam commented 8 years ago

Same error here with Angular 1.4.0

nainyshah commented 8 years ago

To Fix, this issue finds the instructions below.

in your HTML

<ng-csv-import class="import" content="csv.content" header="csv.header" header-visible="csv.headerVisible" separator="csv.separator" separator-visible="csv.separatorVisible" result="csv.result" encoding="csv.encoding" encoding-visible="csv.encodingVisible" callback="csvCallback">

In Controller

$scope.csvCallback = function (result) { // alert("define anything") }

guptaaman2011 commented 8 years ago

not working

lbicknese commented 8 years ago

In the definition of the directive the callback attribute is using = for bidirectional binding; It should probably use & to bind to an expression. This would allow the use of the callback similar to ngChange or ngClick.

nainyshah commented 8 years ago

add this into ur controller.

$scope.csv = { content: null, header: true, headerVisible: true, separator: ',', separatorVisible: true, result: null, encoding: 'ISO-8859-1', encodingVisible: true, accept: true, callback: 'csvCallback' };

$scope.csvCallback = function (result) {
   // alert($scope.res)
}

In ur html it should be like this

<ng-csv-import class="import" content="csv.content" header="csv.header" header-visible="csv.headerVisible" separator="csv.separator" separator-visible="csv.separatorVisible" result="csv.result" encoding="csv.encoding" encoding-visible="csv.encodingVisible" callback="csvCallback">

srokatonie commented 7 years ago

Calback is simply not doing anything... @nainyshah Do you have working example?

nainyshah commented 7 years ago

@srokatonie This code is copied from the project I am working on .......and it works perfectly.

srokatonie commented 7 years ago

@nainyshah turned out I am using outdated (2015) package that was available on npmjs... I build npm package with the most recent version of this repo if anyone needs it: https://www.npmjs.com/package/angular-csv-import-recent

However I noticed when debugging that callback is called many more times, not only when it finishes processing or setting is changed...