TypeError:对象不支持属性或方法' map' NG2-PAGINATE

时间:2017-02-20 11:20:58

标签: angular pagination

我正在尝试在我的angular 2应用程序中使用ng2-paginate实现分页。

我已关注https://github.com/michaelbromley/ng2-pagination链接,最终得到以下system.config.js:

System.config.js

/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {

// map tells the System loader where to look for things
var map = {
'app':                        '/app', // 'dist',

'@angular':                   '/node_modules/@angular',
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
'rxjs': '/node_modules/rxjs',
'ng2-pagination': '/node_modules/ng2-pagination/dist'

};

// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app':                        { main: 'main.js',  defaultExtension: 'js' },
'rxjs':                       { defaultExtension: 'js' },
'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
'ng2-pagination': { main: 'ng2-pagination.js', defaultExtension: 'js' }
};

var ngPackageNames = [
'common',
'compiler',
'core',
'forms',
'http',
'platform-browser',
'platform-browser-dynamic',
'router',
'router-deprecated',
'upgrade',
];

// Individual files (~300 requests):
function packIndex(pkgName) {
packages['@angular/'+pkgName] = { main: 'index.js', defaultExtension: 'js' };
}

// Bundled (~40 requests):
function packUmd(pkgName) {
packages['@angular/'+pkgName] = { main: '/bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
}

// Most environments should use UMD; some (Karma) need the individual index files
var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;

// Add package entries for angular packages
ngPackageNames.forEach(setPackageConfig);

// No umd for router yet
packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };

var config = {
map: map,
packages: packages
};

System.config(config);

})(this);

这是错误堆栈:

Error: TypeError: Object doesn't support property or method 'map'
at ReflectionCapabilities.prototype.parameters (eval code:5006:17)
at Reflector.prototype.parameters (eval code:5191:17)
at CompileMetadataResolver.prototype.getDependenciesMetadata (eval code:13459:13)
at CompileMetadataResolver.prototype.getTypeMetadata (eval code:13420:13)
at CompileMetadataResolver.prototype.getPipeMetadata (eval code:13447:17)
at Anonymous function (eval code:13246:30)
at CompileMetadataResolver.prototype.getNgModuleMetadata (eval code:13236:21)
at Anonymous function (eval code:13228:29)
at CompileMetadataResolver.prototype.getNgModuleMetadata (eval code:13215:21)
at RuntimeCompiler.prototype._compileComponents (eval code:15845:13)
Evaluating http://localhost:53869/app/main.js
Error loading http://localhost:53869/app/main.js

Package.json还会将ng2-paginate的条目显示为依赖项。

有人可以解释为什么会出现此错误。提前谢谢。

1 个答案:

答案 0 :(得分:0)

如果有人在寻找答案,请不要忘记导入所有必需的rxjs扩展名 import 'rxjs/add/operator/map';