【问题标题】:TypeError: Object doesn't support property or method 'map' ng2-paginateTypeError:对象不支持属性或方法'map' ng2-paginate
【发布时间】:2017-08-13 01:57:55
【问题描述】:

我正在尝试在我的 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 的条目显示为依赖项。

谁能解释为什么会发生这个错误。提前致谢。

【问题讨论】:

    标签: angular pagination


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-07-02
      • 2018-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-05
      • 2015-04-14
      • 2020-09-03
      相关资源
      最近更新 更多