问题
I'm trying to follow along with the ng-bootstrap getting started, it says I should import:
import {NGB_DIRECTIVES, NGB_PRECOMPILE} from '@ng-bootstrap/ng-bootstrap';
then request precompile: [ NGB_PRECOMPILE ] in the app.component.ts
I'm getting a big red error in Visual Studio Code, saying
[ts]
Argument of type '{ selector: string; directives: (((typeof NgbAccordion | typeof NgbPanel | typeof NgbPanelTitle)[...' 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...'.
So
and inspecting app I see failed to load resource @ng-bootstrap/ng-bootstrap, but I see a folder @ng-bootstrap and a sub folder named ng-bootstrap in node_modules.
I'm confused because it seems to be telling me on one hand it found it, but it's the wrong type, but on the other it's saying it can't find it at all.
I'm trying this on windows 10 with npm 3.10.6.
Is this a simple issue?
import {Component} from 'angular2/core';
import {NGB_DIRECTIVES, NGB_PRECOMPILE} from '@ng-bootstrap/ng-bootstrap';
import {TestComponent} from './test.component';
@Component({
selector: 'my-app',
directives: [ NGB_DIRECTIVES, TestComponent],
precompile: [ NGB_PRECOMPILE ], //<-- doesn't like this one
template: `<h1>My new App platform</h1>
<test></test>
`
})
export class AppComponent { }
回答1:
This seems like a version issue. precompile was added in rc4
via this commit: github.com/angular/angular/commit/6c5b653
来源:https://stackoverflow.com/questions/38792108/precompile-error-on-ng-bootstrap-ngb-precompile