In Angular2 we add annotations to a component to describe metadata for the given component. I've noticed that ComponentMetadata and ViewMetadata both have templateUrl and template properties. What is the difference between ViewMetadata.template (or templateUrl) vs ComponentMetadata.template, and what would be practical use cases for using one over the other?
2 Answers
In one of the recent updates of angular2, @View was made optional. All of its properties moved into @Components. As of now, @View is redundant.
I my applications, I use only the Component decorators. I find this approach easy to write and maintain.
3 Comments
Yes when Component annotation provide all the functionality then why to use view annotation. according to the Documentation we can skip view annotation because component anno. provide everything which we want from view annotation. but still there is some point why to use view annotation see this answere as said by @alexpods here.
@View()is about to be removed github.com/angular/angular/pull/7495