after updating my project to RC6
following errors occurs:
Error: Typescript found the following errors:
app.component.ts (12, 3): Argument of type '{ moduleId: string; selector: string; templateUrl: string; styleUrls: string[]; directives: (type...' is not assignable to parameter of type 'ComponentMetadataType'.
Object literal may only specify known properties, and 'directives' does not exist in type 'ComponentMetadataType'.
app.component.ts
import {Component, OnInit} from '@angular/core';
import {NavbarComponent} from "./shared/navbar/navbar.component";
import {ROUTER_DIRECTIVES} from "@angular/router";
import {SidebarComponent} from "./shared/sidebar/sidebar.component";
import {FooterComponent} from "./shared/footer/footer.component";
@Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css'],
directives: [NavbarComponent, SidebarComponent, FooterComponent, ROUTER_DIRECTIVES]
})
export class AppComponent implements OnInit {
ngOnInit(): any {
return undefined;
}
}
It take my a while, but I cant figure it out.
Directives
andpipes
must be defined in@NgModule
If I'm reading correctly. Support inside@Component
is removed.So yeah just move your directives into the NgModule
At the moment you have : Component A with directives Ac and Component B with directives Bc and most likely one AppModule, you just have to move Ac and Bc into the AppModule. And yes, you have to remove them from the
@Component
declarationThe directives will then be immediately available in the components that are defined in your module.
Example from OP becomes:
app.component.ts
app.module.ts
See the doc for router: router documentation
For Angular 2 final version 2.0.0.0
the pipe should be declared in declaration section of app.module.ts file
just observe keyspipe implementation in above code snippets.
directives
andpipes
have to be defined in your@NgModule
declarations since RC6. Remove them from your@Component
decorator.