I just upgraded from Angular 2 rc4 to rc6 and had problems with this.
I see the following error on my console:
Unhandled Promise rejection: Template parse errors: 'cl-header' is not a known element: 1. If 'cl-header' is an Angular component, then verify that it is part of this module. 2. If 'cl-header' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schema' of this component to suppress this message. ("<main> [ERROR ->]<cl-header>Loading Header...</cl-header> <div class="container-fluid"> <cl-feedbackcontai"): AppComponent@1:4
Here is my header component:
import { Component } from '@angular/core'; import { Router } from '@angular/router'; // own service import { AuthenticationService } from '../../../services/authentication/authentication.service.ts'; import '../../../../../public/css/styles.css'; @Component({ selector: 'cl-header', templateUrl: './header.component.html', styleUrls: ['./header.component.css'] }) export class HeaderComponent { // more code here... }
Here is my header module:
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { RouterModule } from '@angular/router'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { HeaderComponent } from './../../../components/util_components/header/header.component.ts'; @NgModule({ declarations: [ HeaderComponent ], bootstrap: [ HeaderComponent ], imports: [ RouterModule, CommonModule, FormsModule ], schemas: [ CUSTOM_ELEMENTS_SCHEMA ] }) export class HeaderModule { }
I created a wrapper module called the util module that imports the HeaderModule:
import { NgModule } from '@angular/core'; import {HeaderModule} from "./header/header.module"; // ... @NgModule({ declarations: [ ], bootstrap: [ ], imports: [ HeaderModule] }) export class UtilModule { }
which is finally imported by AppModule:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppComponent } from './app.component'; import {UtilModule} from "./modules/util_modules/util.module"; import {RoutingModule} from "./modules/routing_modules/routing.module"; @NgModule({ bootstrap: [AppComponent], declarations: [AppComponent], imports: [BrowserModule, UtilModule, RoutingModule] }) export class AppModule { }
As far as I understand, I follow the error message instructions using SCHEMA to suppress the error. But it does not seem to work. What am I doing wrong? (I hope that I simply donβt see anything obvious at the moment. I spent the last 6 hours updating this version ...)