0
私はAngular 2アプリを作成しています - Angular quickstartをベースとして使用しています。 Flickityというライブラリをインポートしようとしていますが、成功していません。ライブラリをインポートする角度2
は、これまでのところ: は - 私はnpm install flickity
を使用してライブラリをインストール - それから私は私のsystemjs.config.js
(function (global) {
System.config({
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'...'
// other libraries
'rxjs': 'npm:rxjs',
'flickity': 'npm:flickity',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
}
}
});
})(this);
に置くが、私は私のコンポーネントにFlickityをインポートして使用するようにしようとしているとき、動作しません。 :
import { Component, OnInit } from '@angular/core';
declare var Flickity;
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'app.component.html'
})
export class AppComponent implements OnInit {
ngOnInit() {
console.log(Flickity);
}
}
どうすればいいですか?
可能な複製[angular2にサードパーティのライブラリを追加します。
import Flickity from 'flickity'
また、ライブラリのメインJSファイルがどこにあるか、それは明らかだように、あなたの
System.config.js
に追加しますcli](http://stackoverflow.com/questions/40348533/add-3rd-party-library-to-angular2-cli) –