尝试在ng-seed / universal

时间:2017-07-03 08:21:54

标签: angular ng-bootstrap

我正在尝试按照其自述文件中的步骤将ng-bootstrap添加到ng-seed/universal,但我得到的ng-X组件“不是已知元素”:

'ngb-rating' is not a known element

我尝试在主组件模板中添加一个简单的评级: https://github.com/ng-seed/universal/blob/master/src/client/app/+home/home.component.ts

/src/client/app/+home/home.component.ts中,我在模板中添加了:

<ngb-rating></ngb-rating>

/src/client/app/app.module.ts中,我添加并导入了它:

import { NgbModule } from '@ng-bootstrap/ng-bootstrap';

...

@NgModule({
  declarations: [AppComponent, ...],
  imports: [NgbModule.forRoot(), ...],  
  bootstrap: [AppComponent]
})

我尝试将NgbModule模块导入到主页home.component.ts,但这也无效。

堆栈追踪:

[ERROR ->]<ngb-rating></ngb-rating>"): ng:///HomeModule/HomeComponent.html@1:2
    at Error (native)
    at syntaxError (/temp/universal/.server/server.js:76273:34)
    at TemplateParser.parse (/temp/universal/.server/server.js:86764:19)
    at JitCompiler._compileTemplate (/temp/universal/.server/server.js:100515:39)
    at /temp/universal/.server/server.js:100439:62
    at Set.forEach (native)
    at JitCompiler._compileComponents (/temp/universal/.server/server.js:100439:19)
    at createResult (/temp/universal/.server/server.js:100324:19)
    at ZoneDelegate.invoke (/temp/universal/.server/server.js:72372:26)
    at Object.onInvoke (/temp/universal/.server/server.js:4717:37)
    at resolvePromise (/temp/universal/.server/server.js:72751:31)
    at resolvePromise (/temp/universal/.server/server.js:72722:17)
    at /temp/universal/.server/server.js:72799:17
    at ZoneDelegate.invokeTask (/temp/universal/.server/server.js:72405:31)
    at Object.onInvokeTask (/temp/universal/.server/server.js:4708:37)
    at ZoneDelegate.invokeTask (/temp/universal/.server/server.js:72404:36)
    at Zone.runTask (/temp/universal/.server/server.js:72172:47)
    at drainMicroTaskQueue (/temp/universal/.server/server.js:72565:35)
    at ZoneTask.invoke (/temp/universal/.server/server.js:72471:25)
    at data.args.(anonymous function) (/temp/universal/.server/server.js:73255:25)

1 个答案:

答案 0 :(得分:0)

在您的组件中添加selector

import { Component } from '@angular/core';

@Component({
  selector: 'ngb-rating',
  template: `ng-seed (universal) home page<br/>
  Enjoy it!<br/>`
})
export class HomeComponent {
}