Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 RC6 - "sidebar" is not a known element

I just updated to RC6 and have trouble with the following error:

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 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>
...

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

But that doesn't seem to do anything.

Does anyone haven an idea or a hint?

like image 392
Philipp Avatar asked Dec 08 '22 21:12

Philipp


1 Answers

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 { }
like image 53
Philipp Avatar answered Dec 10 '22 13:12

Philipp