2017-02-20 36 views
1

我正在嘗試將分頁引入到我的應用程序中,但卻出現錯誤。我下面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": {} 
} 

有沒有別人可以與幫助。提前致謝。

回答

1

你應該更新你的角度版本。由於2.0.0-rc.6Type類現在是通用的(意思是Type<T>)。 Ng2-bootstrap顯然更新了他們的代碼以符合這一變化。

我也可以建議你回去幾個版本與ng2-bootstrap,但爲什麼住在過去。你應該更新到最新的角度。 RC-5近半年前發佈,遷移到發佈版本而不是停留在候選版本發佈狀態將不僅僅是解決這個問題。

+0

所以我應該只更新package.json中提到的'rc5'到'rc6'並保留其他依賴關係? –

+0

那麼,解決你的問題。是的,那會起作用。但爲什麼你想留在發佈候選版本? – PierreDuc

+0

如果不是'rc'應該將我的依賴關係遷移到哪個穩定版本? –