Angular 2 RC6 - “sidebar” is not a known element

北慕城南 提交于 2019-12-04 10:08:12
Philipp

Thanks to Pankaj Parkar for his comment.

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 {}

Include it in app.module.ts

@NgModule({
    declarations: [..., SidebarDirective],
...
})
export class AppModule { }

Rather than go for workaround I'd say that whenever you wanted to create component, have some suffix before component selector. Like suppose my application name is MoneyManagement so then I'll be adding mm- before each of my application component. This habit will reduce the chances to conflict with any reserve HTML tag/element or sidebar component added by plugin.

Unlike the workaround would not work in future when you add bootstrap/any plugin component here which has sidebar component already defined.

Just following such kind of convention would avoid this issue in future.

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