2
votes

I just started coding a fresh new angular2 app that I cloned from https://github.com/angular/quickstart

Why am I getting this error?

app/app.component.ts(8,3): error TS2345: Argument of type '{ moduleId: string; selector: string; templateUrl: string; directives: string[]; }' is not assignable to parameter of type 'Component'. Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.

app.component.ts

import { Component } from '@angular/core';
import { NavbarComponent } from './components/navbar/navbar.component';

@Component({
  moduleId: module.id,
  selector: 'my-app',
  templateUrl: 'app.component.html',
  directives: [NavbarComponent]
})
export class AppComponent  {  }

navbar-component.ts

import { Component } from '@angular/core';

@Component({
  moduleId: module.id,
  selector: 'navbar',
  templateUrl: `navbar.component.html`,
})
export class NavbarComponent  {  }
1

1 Answers

6
votes

Remove below line from app.component.ts

directives: [NavbarComponent]

And add it in app.module.ts

@NgModule({
  imports:      [ BrowserModule ],
  declarations: [ AppComponent, NavbarComponent ], << add here
  bootstrap:    [ AppComponent ]
})

directives is no longer available from 2.0.0-rc.6