Angular 2.0. Difference @View @Component

后端 未结 4 2003
一生所求
一生所求 2020-11-29 11:22

Hi. I\'m new to Angular. I\'m testing Angular 2.0.

I read the tuto here and the guide here. In the tuto, the template is specified in the @Component ann

4条回答
  •  感情败类
    2020-11-29 11:38

    First of all, this was deprecated and now fully gone!

    2.0.0-beta.10 (2016-03-17): @View() annotation (previously deprecated) has been removed. Apps should use the @Component() decorator instead.

    So you don't need to worry about it anymore, The @View was previously introduced because the early thinking was that there could be multiple views in a component (like a mobile view for example) and the usage was as below:

        import { Component } from '@angular/core';
    
        @Component({
          selector: 'app-root',
          styleUrls: ['./app.component.scss']})
        @View({
          media: 'desktop',
          template: '

    tablet

    ' }) @View({ media: 'mobile', template: '

    mobile

    ' }) extends class Component() {}

提交回复
热议问题