Precompile fails when adding ng-bootstrap to an Angular-CLI project

折月煮酒 提交于 2019-12-25 04:25:43

问题


When i try to add ng-bootstrap to Angular-CLI project according to https://stackoverflow.com/a/38413274/1596547, i can't not use the 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;
}

The above generates the following error:

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:


This seems like a version issue. precompile was added in rc4

via this commit: github.com/angular/angular/commit/6c5b653

rc4 changelog: https://github.com/angular/angular/blob/master/CHANGELOG.md (look under features)



来源:https://stackoverflow.com/questions/38696508/precompile-fails-when-adding-ng-bootstrap-to-an-angular-cli-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!