Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we stop using @View annotation and only use @Component in Angular 2 components?

Tags:

angular

All of the properties of the @View annotation are also present in @Component. Earlier examples used both, but since beta.8 (and maybe earlier) the code samples on angular.io website only use @Component. Is this the preferred way of creating components?

like image 686
Joseph Genchik Avatar asked Mar 07 '16 19:03

Joseph Genchik


2 Answers

I am pretty sure that the @View decorator will be removed. You can use the template key in the @Component decorator to specify the view template. Also when you look for @View in the docs you can see that the example is not in line with what is written https://angular.io/docs/ts/latest/api/core/View-decorator.html

To me it highly suggests that it is going to be removed.

like image 55
Michelangelo Avatar answered Nov 15 '22 03:11

Michelangelo


update

@View() is about to be removed https://github.com/angular/angular/pull/7495


It's not sure @View will stay supported. They discussed removing it. As far as I know they still plan to add support for multiple views but it's not decided yet how the approach will look like.

See also https://github.com/angular/angular/issues/7363

like image 38
Günter Zöchbauer Avatar answered Nov 15 '22 03:11

Günter Zöchbauer