Angular 2.0. Difference @View @Component

Update

@View() was removed (I think in beta.13, the CHANGELOG.md doesn’t mention it though).

Original

There are no differences between them. It’s just sugar that you can specify all view configuration into Component so there’s no need to import View decorator.

But at the same time there’s a need to remain View decorator exist, because it allows us to use different views for the same component depending on language or media type. For example:

@Component(/* ... */)
@View({
  media: 'desktop',
  template: 'Template for desktop'
})
@View({
  media: 'mobile',
  template: 'Template for mobile'
})
extends class Component() {}

This feature is not implemented yet.

Leave a Comment