角2.0​​。差异@View @Component [英] Angular 2.0. Difference @View @Component

查看:298
本文介绍了角2.0​​。差异@View @Component的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜。我是新来的角。我测试角2.0。

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

我读到这里的政党成员和引导的here 。在的tuto,模板在@Component注释指定而引导在其处于@View注解。所以我想知道什么是两种方法之间的区别?我抬起头,在API preVIEW但解释不清楚。

I read the tuto here and the guide here. In the tuto, the template is specified in the @Component annotation whereas in the guide it is in the @View annotation. So I was wondering what are the differences between the two approaches ? I looked up in the api preview but the explanations were not clear.

推荐答案

有它们之间没有差异。这只是糖,你可以指定所有的视图配置到组件,所以没有需要导入查看装饰。

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() {}

此功能尚未实现。

这篇关于角2.0​​。差异@View @Component的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆