将 NGB_ALERT_DIRECTIVES 从 ng-bootstrap 添加到 Angular-CLI 项目时出错

Error when adding the NGB_ALERT_DIRECTIVES from ng-bootstrap to an Angular-CLI project

我尝试将 ng-bootstrap 的警报指令 (NGB_ALERT_DIRECTIVES) 添加到 Angular-CLI 项目。我按照 .

中描述的步骤操作

上述导致以下错误:

EXCEPTION: Can't resolve all parameters for NgbDismissibleAlert: (TemplateRef, ViewContainerRef, Injector, ?, Renderer).

如何解决以上问题,是否与预编译选项有关?参见:

问题与angular版本有关,将angular更新为Angular2 RC4即可解决。

在 angular-cli 的 package.json 中使用以下依赖项:

  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-alpha.8",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.1",
    "es6-shim": "0.35.1",
    "ng2-bootstrap": "^1.0.24",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.26",
    "zone.js": "0.6.12"
  },

运行 npm update 问题就解决了。该错误与预编译选项无关。