5

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?

bflemi3
  • 6,698
  • 20
  • 88
  • 155

2 Answers2

5

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.

Kismu
  • 76
  • 4
  • 1
    And this is why I dislike Angular 2.0. Arbitrary changes made optional, lack of documentation. – lux Dec 28 '15 at 15:12
  • 1
    Here are the specifics on where/when @View was made redundant. Ref: https://github.com/angular/angular/pull/4566 – Evan Plaice Feb 21 '16 at 07:48
  • @lux The project was just released from beta. The project has consistently had 1000+ issues since the beta.0 release. Exercise a little patience, documentation will come with time. – Evan Plaice Feb 21 '16 at 07:49
0

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.

Community
  • 1
  • 1
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215