[英]How to load third party library in Angular2
I am trying to implement a Datepicker in Angular 2. But the library is not loading due to which I am getting template parsing error 'material-datepicker' is not a known element: 我正在尝试在Angular 2中实现Datepicker。但是由于我正在获取模板解析错误'material-datepicker',所以该库未加载,这是一个未知的元素:
I have my System.config.js as below. 我的System.config.js如下。
(function (global) {
System.config({
paths: {
'npm:': 'node_modules/'
},
map: {
app: 'app',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-material-datepicker': 'npm:angular2-material-datepicker'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: '../dist/main.js',
defaultExtension: 'js'
},
rxjs: {
defaultExtension: 'js'
},
'angular2-material-datepicker': {
main: 'index.js',
defaultExtension: 'js',
}
}
});
})(this);
import the module into your AppComponent and any component in which you use it. 将模块导入到AppComponent和使用它的任何组件中。
import { DatepickerModule } from 'angular2-material-datepicker'
@NgModule({
imports: [ DatepickerModule ],
declarations: [ ... ],
bootstrap: [ ... ]
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.