输入' Type'不是通用的

时间:2017-02-20 14:47:32

标签: angular pagination ng2-bootstrap

我正在尝试将分页引入我的应用程序,但收到错误。我正在关注ng2-bootstrap

这就是我在组件中声明字段的方式:

 public bigTotalItems: number = IEmployee.length;
 public maxSize: number = 5;

这就是我在模板中使用它们的方式:

<pagination [totalItems]="bigTotalItems" [maxSize]="maxSize" class="pagination-sm"
                        [boundaryLinks]="true"></pagination>

继承我的app.module.ts:

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { HttpModule } from '@angular/http';
import { PaginationModule } from 'ng2-bootstrap';

@NgModule({
    imports: [PaginationModule.forRoot(),BrowserModule, FormsModule, HttpModule ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]

})
export class AppModule { }

我在component-loader.class.d.ts文件中收到此错误。

还附加package.json以共享我正在使用的依赖项版本:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "description": "QuickStart package.json from the documentation, supplemented with testing support",
  "scripts": {
    "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
    "docker-build": "docker build -t ng2-quickstart .",
    "docker": "npm run docker-build && docker run -it --rm -p 3000:3000 -p 3001:3001 ng2-quickstart",
    "pree2e": "npm run webdriver:update",
    "e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first",
    "lint": "tslint ./app/**/*.ts -t verbose",
    "lite": "lite-server",
    "postinstall": "typings install",
    "test": "tsc && concurrently \"tsc -w\" \"karma start karma.conf.js\"",
    "test-once": "tsc && karma start karma.conf.js --single-run",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings",
    "webdriver:update": "webdriver-manager update"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.5",
    "@angular/compiler": "2.0.0-rc.5",
    "@angular/core": "2.0.0-rc.5",
    "@angular/forms": "0.3.0",
    "@angular/http": "2.0.0-rc.5",
    "@angular/platform-browser": "2.0.0-rc.5",
    "@angular/platform-browser-dynamic": "2.0.0-rc.5",
    "@angular/router": "3.0.0-rc.1",
    "@angular/upgrade": "2.0.0-rc.5",
    "angular2-in-memory-web-api": "0.0.15",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "ng2-bootstrap": "^1.3.3",
    "ng2-paginate": "^0.1.0",
    "ng2-pagination": "^2.0.0",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12"
  },
  "devDependencies": {
    "concurrently": "^2.2.0",
    "lite-server": "^2.2.0",
    "typescript": "^1.8.10",
    "typings": "^1.0.4",
    "canonical-path": "0.0.2",
    "http-server": "^0.9.0",
    "tslint": "^3.7.4",
    "lodash": "^4.11.1",
    "jasmine-core": "~2.4.1",
    "karma": "^0.13.22",
    "karma-chrome-launcher": "^0.2.3",
    "karma-cli": "^0.1.2",
    "karma-htmlfile-reporter": "^0.2.2",
    "karma-jasmine": "^0.3.8",
    "protractor": "^3.3.0",
    "rimraf": "^2.5.2"
  },
  "repository": {}
}

是否有人可以提供帮助。提前谢谢。

2 个答案:

答案 0 :(得分:1)

您应该更新角度版本。由于2.0.0-rc.6 Type类现在是通用的(这意味着Type<T>)。 Ng2-bootstrap显然更新了他们的代码以符合这一变化。

我还建议您使用ng2-bootstrap返回几个版本,但为什么要留在过去。你应该只更新到最新的角度。 RC-5几乎在半年前发布,迁移到发布版本而不是留在候选版本状态将有助于解决这个问题。

答案 1 :(得分:1)

我的问题是导入错误,因此请确保您从Type导入了正确的@angular/core

import { Type } from '@angular/core';