Angular2 Component Template vs View Template

In Angular2, we add annotations to a component to describe the metadata for that component. I noticed that ComponentMetadata and ViewMetadata have the properties templateUrl and template . What is the difference between ViewMetadata.template (or templateUrl ) vs ComponentMetadata.template and what will be practical examples of using one over the other?

+5
source share
2 answers

In one of the latest updates to angular2, @View has been made optional. All its properties have moved to @Components. @View is currently redundant.

In my applications, I use only Component decorators. I find this approach easy to write and maintain.

+5
source

Yes, when a component annotation contains all the functionality, then why use a view annotation. according to the Documentation, we can skip the view annotation because the anno component. provide everything we want from the annotation of the view. but still there is some point why to use view annotation see this answer as @alexpods says here.

0
source

Source: https://habr.com/ru/post/1237139/


All Articles