角度2 RC6-“侧边栏"不是一个已知的元素 [英] Angular 2 RC6 - "sidebar" is not a known element
问题描述
我刚刚更新到RC6,遇到以下错误:
I just updated to RC6 and have trouble with the following error:
zone.min.js:1未处理的承诺拒绝:模板解析错误: 侧边栏"不是已知元素: 1.如果侧边栏"是Angular组件,则确认它是该模块的一部分. 2.如果'sidebar'是Web组件,则将"CUSTOM_ELEMENTS_SCHEMA"添加到该组件的'@ NgModule.schema'以禁止显示此消息. ("
zone.min.js:1 Unhandled Promise rejection: Template parse errors: 'sidebar' is not a known element: 1. If 'sidebar' is an Angular component, then verify that it is part of this module. 2. If 'sidebar' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("
sidebar
不是组件.我在一个模板中使用的只是一个html标签.他们看起来像这样:
sidebar
isn't a component. Just a html-tag i am using in one of my templates. They look like this:
...
<sidebar class="main-nav">
...
</sidebar>
...
我尝试用CUSTOM_ELEMENTS_SCHEMA
这样更新我的NgModule AppModule:
I tried updating my NgModule AppModule with CUSTOM_ELEMENTS_SCHEMA
like this:
@NgModule({
declarations: [...],
providers: [...],
imports: [BrowserModule, routing, HttpModule, FormsModule, TranslateModule.forRoot()],
bootstrap: [AppComponent],
schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule { }
但这似乎无济于事.
有人没有想法或提示吗?
Does anyone haven an idea or a hint?
推荐答案
感谢 Pankaj Parkar 的评论
sidebar
似乎尚未被接受.我必须实施变通方法.
sidebar
seems not to to be accepted yet. I had to implement a workaround.
sidebar.directive.ts
import { Directive } from '@angular/core';
/**
* dummy directive to allow html-tag "sidebar"
*/
@Directive({ selector: 'sidebar'})
export class SidebarDirective {}
将其包含在app.module.ts
Include it in app.module.ts
@NgModule({
declarations: [..., SidebarDirective],
...
})
export class AppModule { }
这篇关于角度2 RC6-“侧边栏"不是一个已知的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!