我正在使用 systemjs.config、angular 4 和 ng2-toastr 版本 4.0.1 运行应用程序时出现错误“无法读取未定义的属性 'forRoot'”似乎没有从 ng2-bootstrap 加载 ToastModule 或任何类
这是 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
'@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/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.min.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',
'ng2-toastr': 'npm:ng2-toastr/bundles/ng2-toastr.min.js',
'ng2-validation': 'npm:ng2-validation/bundles/ng2-validation.umd.js',
'libphonenumber-js': 'npm:libphonenumber-js/bundle/libphonenumber-js.min.js',
// other libraries
'rxjs': 'npm:rxjs',
'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'
},
'ng2-toastr': {
defaultExtension: 'js'
},
'ng2-validation': {
defaultExtension: 'js'
}
}
});
})(this);
这是我加载 toastr 的核心模块
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { CustomFormsModule } from 'ng2-validation'
import { ToastModule } from 'ng2-toastr';
@NgModule({
imports: [BrowserModule, CustomFormsModule, ToastModule.forRoot()],
providers: [}],
declarations: [],
bootstrap: []
})
export class CoreModule { }