How to add NPM package to the plunker correctly?

I got an error when using angular2 -infinite-scroll . I want to play it in plunkr.

I tried using npmcdn , so I am adding this line to the index.html file:

<script src="https://npmcdn.com/ angular2-infinite-scroll@0.1.2 "></script> 

But I got an error:

Untrained ReferenceError: require not defined

This is my plunker .

How can I add the NPM package correctly to the plunker?

+7
angular npm plunker
source share
1 answer

Add it to the map object in your config.js file, and possibly also in the packages object if there is no index.js in the package.

 map: { [...], 'angular2-infinite-scroll': 'https://npmcdn.com/ angular2-infinite-scroll@0.1.2 ' }, packages: { [...], 'angular2-infinite-scroll': { main: 'angular2-infinite-scroll.js', defaultExtension: 'js' } }, 

running plunker

+8
source share

All Articles