将ng-bootstrap添加到Angular-CLI项目时,预编译失败

时间:2016-08-01 10:27:04

标签: angular angular-cli ng-bootstrap

当我尝试根据https://stackoverflow.com/a/38413274/1596547向ngular-CLI项目添加ng-bootstrap时,我不能使用procompile option

import { Component } from '@angular/core';
import {NGB_ALERT_DIRECTIVES,NGB_PRECOMPILE} from '@ng-bootstrap/ng-bootstrap';

@Component({
  moduleId: module.id,
  selector: 'app-root',
  directives: [ NGB_ALERT_DIRECTIVES ],
  precompile: [ NGB_PRECOMPILE ],
  templateUrl: 'app.component.html',
  styleUrls: ['app.component.css']
})
export class AppComponent {
  title = 'app works!';
  public isCollapsed:boolean = false;
}

以上会产生以下错误:

Error: Typescript found the following errors:
  /home/bass/testdrive/bootstrap-angular/tmp/broccoli_type_script_compiler-input_base_path-tcvIrPf2.tmp/0/src/app/app.component.ts (9, 3): Argument of type '{ moduleId: string; selector: string; directives: (typeof NgbAlert | typeof NgbDismissibleAlert)[...' is not assignable to parameter of type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'.
  Object literal may only specify known properties, and 'precompile' does not exist in type '{ selector?: string; inputs?: string[]; outputs?: string[]; properties?: string[]; events?: strin...'.

1 个答案:

答案 0 :(得分:1)

这似乎是一个版本问题。在rc4中添加了预编译

通过此提交:github.com/angular/angular/commit/6c5b653

rc4更改日志:https://github.com/angular/angular/blob/master/CHANGELOG.md(查看功能)