Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2.0 Release: Pipes and Directives are not properties of @Component anymore

I just upgraded my app which I built on RC5 to the final release, and I'm confused of the way I should be declaring Directives and Pipes now. I'm getting this error:

ERROR in [default] C:\xampp\htdocs\meriem-car\public\src\app\components\administration.component.ts:12:4 Argument of type '{ moduleId: string; selector: string; directives: typeof LoginComponent[]; templateUrl: string; }' is not assignable to parameter of type 'Component'. Object literal may only specify known properties, and 'directives' does not exist in type 'Component'.

like image 680
Motassem MK Avatar asked Sep 16 '16 19:09

Motassem MK


People also ask

What is the difference between @component and @directive in angular?

The Component is used to break up the application into smaller components. That is why components are widely used in later versions of Angular to make things easy and build a total component-based model. The Directive is used to design reusable components, which are more behavior-oriented.

What is difference between pipe and directive in angular?

Pipes are for formatting data, directives are to alter the behavior/appearance of an element.

What are directives and components in angular?

A component is a single unit that encapsulates both view and logic whereas directives are used to enhance the behavior of components or dom elements and it doesn't have any templates. Component extends directive so every component is a directive.


1 Answers

Since RC6, all Directives and Pipes should be moved to module's declarations.

@NgModule({
    imports: [...],
    declarations: [
        //you insert your Components, Directives and Pipes here
    ],
    bootstrap: [...],
    providers: [...]
})

export class AppModule { }
like image 87
Stefan Svrkota Avatar answered Sep 18 '22 13:09

Stefan Svrkota