【发布时间】:2016-07-12 03:11:14
【问题描述】:
尝试两个将 ng-pagenation 添加到我的 angular-cli 应用程序中的组件 不断收到我无法诊断的错误,请大家帮忙
节点版本 4.4.5
npm 版本 3.8.7
angular-cli: 1.0.0-beta.8
**// admin component**
import { Component, OnInit,ChangeDetectionStrategy }
from'@angular/core';
import {AdminService} from '../admin.service';
import {PaginatePipe,PaginationService, PaginationControlsCmp} from
'ng2-分页';
@Component({
moduleId: module.id,
selector: 'app-admin',
templateUrl: 'admin.component.html',
styleUrls: ['admin.component.css'],
providers:[AdminService,PaginationService],
pipes:[PaginatePipe]
})
export class adminComponent implements OnInit {
public approvedPrayers;
public unApprovedPrayers;
public prayer_error:Boolean = false;
constructor(private adminService:AdminService) {}
ngOnInit() {
}}
**// index.html**
<!doctype html>
<html>
<head>
<base href="/">
<meta charset="utf-8">
<title>Prayerbox</title>
<base href="/">
**<script src="https://rawgit.com/michaelbromley/
ng2-pagination/master/dist/ng2-pagination-bundle.js"></script>**
{{#unless environment.production}}
<script src="/ember-cli-live-reload.js" type="text/javascript"></script>
{{/unless}}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root>Loading...</app-root>
{{#each scripts.polyfills}}
<script src="{{.}}"></script>
{{/each}}
<script>
System.import('system-config.js').then(function () {
System.import('main');
}).catch(console.error.bind(console));
</script>
</body>
</html>
//错误
ng2-pagination-bundle.js:10 Uncaught ReferenceError: System is not
defined(anonymous function) @ ng2-pagination-bundle.js:10
zone.js:461 Unhandled Promise rejection: Error: XHR error
(404 Not Found)loading http://localhost:4200/ng2-pagination/index.js
【问题讨论】:
-
可以尝试在 index.html 中 polyfills 后导入 ng2-pagination 脚本
-
我在系统配置中唯一做的就是这个 // 第三方桶。 'rxjs', 'ng2-分页',
标签: angular pagination