mtr / angular-iscroll

AngularJS module that enables iScroll 5 functionality, wrapping it in an easy-to-use directive.
MIT License
74 stars 27 forks source link

Keep getting "TypeError: IScroll is not a function" #16

Closed tulumario closed 7 years ago

tulumario commented 9 years ago

I don't get it why, but I have configured it like any other script but still I'm getting an error: "TypeError: IScroll is not a function at _createInstance (http://192.168.15.43/DFSWeb/js/lib/angular-iscroll.js:163:28)"

As I see, it looks like it doesn't recognize IScroll in a script. Can someone tell me why is that. My config looks like: require.config({ baseUrl: 'js', waitSeconds: 500, paths: { .... 'angular-iscroll': 'lib/angular-iscroll', ... }, shim: { ... 'angular-iscroll': ['angular'], 'filter-controller': ['jquery', 'angular', 'angular-iscroll', 'factory', 'spinner'], ... } require(['app-start'], function () { window.console.log('application started...'); } );

And my controller looks like:

define(['angular'], function(){ 'use strict';

var app = angular.module('filter', ['constants', 'angular-iscroll'])

app.controller('filterController', [..., 'iScrollService', function (..., iScrollService) { var vm = this; // Use 'controller as' syntax

   vm.iScrollState = iScrollService.state;
   ...

}

sdsanders commented 9 years ago

I'm getting this as well, did you ever figure it out?

sdsanders commented 9 years ago

It would seem that the iscroll dependency didn't get installed when I installed angular-iscroll with bower, manually installing iscroll with bower install iscroll fixed it.

mtr commented 9 years ago

Thank you for figuring that out, @sdsanders!

I don't use bower myself (only npm), so I haven't been experienced that error. Do you know a way to fix this so that bower will install it correctly, automatically?

karneaud commented 8 years ago

Bump

karneaud commented 8 years ago

@sdsanders @mtr ever figured this out?

mtr commented 8 years ago

I am sorry, but I haven't had the time yet to look into defining a Bower configuration for this package.

Just in case anyone else ends up in this thread: the error reported seems to be caused by that the original, non-AngularJS iscroll script is not being loaded before the AngularJS module tries to use it. And, as @sdsanders pointed out, that again seems to happen when you install the angular-iscroll package via Bower. However, since I'm not using Bower myself, I haven't had the time to create a proper Bower configuration for the package. If anyone wants to contribute, I would be happy to merge in such a file.

nhuthuynh commented 8 years ago

another issue like this one is using 'use strict', it should be "new window.IScroll" in _createInstance function to fix.

solidsquare commented 8 years ago

I did not have this specific problem, but it may be related to iscroll not having a bower.json file with a main defined. You can supply a main in your own bower.json by adding: "overrides": { "iscroll": { "main": "build/iscroll.js" } }