我按照https://ng-bootstrap.github.io/#/getting-started的说明将ngbootstrap添加到Angular2项目中。但现在,当我编译它时,我得到了错误
- @ ng-bootstrap / ng-bootstrap / pagination / pagination.d.ts(52,14):错误TS1005:'='预期。
- @ ng-bootstrap / ng-bootstrap / pagination / pagination.d.ts(52,23):错误TS1005:';'预期。
- @ ng-bootstrap / ng-bootstrap / pagination / pagination.d.ts(52,14):错误TS2304:找不到名称'pageCount'。
此外,网站上未正确显示引导程序组件。
答案 0 :(得分:0)
这是我的package.json:
{
"name": "webshop",
"version": "0.1.0",
"scripts": {
"build": "webpack --progress",
"build:prod": "webpack -p --progress",
"postinstall": "typings install",
"serve": "webpack-dev-server --inline --progress"
},
"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/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.5",
"@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.8",
"angular2-in-memory-web-api": "0.0.15",
"bootstrap": "^4.0.0-alpha.4",
"core-js": "2.4.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12"
},
"devDependencies": {
"browserify": "^13.1.0",
"html-webpack-plugin": "^2.17.0",
"ts-loader": "^0.8.2",
"tsify": "^1.0.7",
"typescript": "^1.8.10",
"typings": "^1.0.4",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
}
}
这里是app.module.ts:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NavbarModule } from './navbar';
import { AppComponent } from './app.component';
@NgModule({
imports: [ NgbModule.forRoot(), BrowserModule, NavbarModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
我没有system.js
答案 1 :(得分:0)
我不是100%肯定,但我认为这与使用的打字稿版本有关。 ng-bootstrap已经开始使用一些打字稿v2的功能,这些功能打破了typescript v1.8的变化。您从库中获得的VS扩展实现了v1.8,因此无法再编译ng-bootstrap。
[编辑]修正了它! 您需要更新visual studio 2015以更新3, 从这里下载并安装新的typescript 2工具; https://www.microsoft.com/en-us/download/details.aspx?id=48593 然后编辑.csproj文件并更改此标记
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
说
<TypeScriptToolsVersion>2.0</TypeScriptToolsVersion>
然后VS将使用最新的打字稿构建,识别新的语言功能并构建好。