Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

javascript - Difficulties loading angular2-infinite-scroll

I am getting 2 errors on my app:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3002/angular2-infinite-scroll

angular2-polyfills.js:1243 Error: XHR error (404 Not Found) loading http://localhost:3002/angular2-infinite-scroll(…)

Here is the page in question:

import {Component} from 'angular2/core';
import {Router, CanDeactivate} from 'angular2/router';
import { InfiniteScroll } from 'angular2-infinite-scroll';

@Component({
selector: 'dapps',
directives: [ InfiniteScroll ],
templateUrl: '/app/dapps/templates/dapps.component.html',

Down further in the component I have:

onScroll () {
    console.log('scrolled!!')
}

I installed the Infinite scroll npm package using:

 npm install angular2-infinite-scroll --save

In the template file for the component I have:

<div class="row" infinite-scroll
        [infiniteScrollDistance]="2"
        [infiniteScrollThrottle]="500"
        (scrolled)="onScroll()">
</div>

edit tried:

config.js on root:

System.config({
//use typescript for compilation
transpiler: 'typescript',
//typescript compiler options
typescriptOptions: {
emitDecoratorMetadata: true
},
//map tells the System loader where to look for things
map: {
'angular2-infinite-scroll': '~/angular2-infinite-scroll'
},
//packages defines our app package
packages: {
'angular2-infinite-scroll': {
main: 'angular2-infinite-scroll.js',
defaultExtension: 'js'
}
}

});

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have to configure the angular2-infinite-scroll in your systemjs config. See the config.js file in the example plunk:

https://plnkr.co/edit/DzKAiAxtAleIrT0tsqtj?p=preview

 map: {

   'angular2-infinite-scroll': 'node_modules/angular2-infinite-scroll'
}

and for the packages object add:

'angular2-infinite-scroll': {
  main: 'angular2-infinite-scroll.js',
  defaultExtension: 'js'
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...