我使用Angular2创建了小应用程序,我在Chrome浏览器中遇到以下错误:
zone.js:323 Error: ReferenceError: packages is not defined
at materialComponents.forEach.name (http://localhost:4200/system-config.js:17:5)
at Array.forEach (native)
at eval (http://localhost:4200/system-config.js:16:20)
Evaluating http://localhost:4200/system-config.js
Error loading http://localhost:4200/system-config.js
基本上,这个错误发生在以下代码上。
系统config.ts
/** Map relative paths to URLs. */
const map: any = {
'@angular2-material': 'vendor/@angular2-material', // created in vendor directory
'ng2-material': 'vendor/ng2-material',
'moment': 'vendor/moment/moment.js'
};
/** User packages configuration. */
const packages: any = {};
// Material Components
const materialComponents = [
'core',
'checkbox',
'input',
'progress-bar',
'progress-circle',
'radio',
'sidenav',
'slide-toggle',
'toolbar'
];
materialComponents.forEach(name => { //Here it says package not defined
packages[`@angular2-material/${name}`] = {
format: 'cjs',
defaultExtension: 'js',
main: name + '.js'
};
});
由于