sroze / ngInfiniteScroll

Infinite Scrolling for AngularJS
http://sroze.github.com/ngInfiniteScroll/
MIT License
2.89k stars 723 forks source link

Documentation on github #354

Closed carmelolg closed 7 years ago

carmelolg commented 7 years ago

The correct module name to inject inside module dependencies is: infinite-scroll and not ngInfiniteScroll

graingert commented 7 years ago

I don't understand what you mean: the module name for this angular module is intentionally left unspecified because ESM and CJS are the preferred ways of accessing the module.

Can you create a PR with your change?

carmelolg commented 7 years ago

Related to: https://github.com/sroze/ngInfiniteScroll#getting-started

const MODULE_NAME = 'myApplication'; angular.module(MODULE_NAME, [ngInfiniteScroll]); export default MODULE_NAME;

This code doesn't work because the module name of 1.3.4 version is infinite-scroll so imho has to be changed on

const MODULE_NAME = 'myApplication'; angular.module(MODULE_NAME, [infinite-scroll]); export default MODULE_NAME;

File ng-infinite-scroll.js row 29: var MODULE_NAME = 'infinite-scroll';

let me know

graingert commented 7 years ago
import angular from 'angular';
import ngInfiniteScroll from 'ng-infinite-scroll';

const MODULE_NAME = 'myApplication';
angular.module(MODULE_NAME, [infinite-scroll]);
export default MODULE_NAME;

would result in:

ReferenceError: infinite is not defined
carmelolg commented 7 years ago

@graingert in my case it works, my version is "ngInfiniteScroll": "^1.3.4"

File ng-infinite-scroll.js row 29: var MODULE_NAME = 'infinite-scroll';

carmelolg commented 7 years ago

Maybe I badly explained myself. When you inject this dependencies on your app.module.js the correct inject is infinite-scroll and not ngInfiniteScroll.

graingert commented 7 years ago

@carmelolg as I said using angular.module(MODULE_NAME, [infinite-scroll]); would result in:

ReferenceError: infinite is not defined

Even if infinite and scroll were both defined infinite-scroll would be a Number.

carmelolg commented 7 years ago

Okay, but has to be a string. Change with 'infinite-scroll' let me know

graingert commented 7 years ago

when you do

import ngInfiniteScroll from 'ng-infinite-scroll';

ngInfiniteScroll // is a string;
graingert commented 7 years ago

the module name string 'infinite-scroll' is intentionally unspecified and could change at any time, without being a semver change.

carmelolg commented 7 years ago

okay the problem is that I'm using Angular 1.5.X and not Angular2

graingert commented 7 years ago

This project doesn't support Angular 2. It's angularjs only

carmelolg commented 7 years ago

So, what can I do? Now I inject 'infinite-scroll' and it works. My project is something like: angular.module('myApp', ['infinite-scroll']); with angular.module('myApp', ['ngInfiniteScroll']); doesn't work

graingert commented 7 years ago

You should use:

import angular from 'angular';
import ngInfiniteScroll from 'ng-infinite-scroll'; // this bit makes ngInfiniteScroll a string.

const MODULE_NAME = 'myApp';
angular.module(MODULE_NAME, [ngInfiniteScroll]);
export default MODULE_NAME;
carmelolg commented 7 years ago

I'm not agree with this declaration of module. Have to be compatible in my opinion also with standard declaration of module.

graingert commented 7 years ago

you can still use legacy JS:

'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _angular = require('angular');

var _angular2 = _interopRequireDefault(_angular);

var _ngInfiniteScroll = require('ng-infinite-scroll');

var _ngInfiniteScroll2 = _interopRequireDefault(_ngInfiniteScroll);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var MODULE_NAME = 'myApp';
_angular2.default.module(MODULE_NAME, [_ngInfiniteScroll2.default]);
exports.default = MODULE_NAME;
carmelolg commented 7 years ago

I continue to be disagree but I will accept. Thank you.