4

I am hoping someone can clear this up for me. I am assuming there is an easy answer to this. But if its out on the internet I can't seem to find it. Keep in mind, I have little angular 1 experience, so I apologize if I am missing something obvious.

I have seen the following examples out there for creating a template in Angular 2.

//Example 1

@Component({
   selector: 'my-app'
})

@View({
  template : '<p></p>'
})

As I understand it, the above example is the same as this.

// Example 2

@Component({
   selector: 'my-app',
   template: '<p></p>'
})

According to this https://angular.io/docs/ts/latest/api/core/View-decorator.html and this @Directive v/s @Component in angular2

So is there any good reason to create templates like the first example vs the second where @View seems to be implicitly set via @Component using "template:"?

Community
  • 1
  • 1
khollenbeck
  • 16,028
  • 18
  • 66
  • 101

1 Answers1

1

I think that you should have a look at this question: Angular 2.0. Difference @View @Component.

Your example1 and example2 actually do the same thing...

In fact, it's the same since View is optional but in the future, you will be able to define several views for a same component.

Hope it helps you, Thierry

Community
  • 1
  • 1
Thierry Templier
  • 198,364
  • 44
  • 396
  • 360