Angular2组件模板VS查看模板 [英] Angular2 Component template vs View template

查看:96
本文介绍了Angular2组件模板VS查看模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Angular2我们添加注释组件来描述元数据给定组件。我注意到 ComponentMetadata ViewMetadata 都有 templateUrl 模板属性。是什么 ViewMetadata.template 之间的差异(或 templateUrl )VS ComponentMetadata.template ,并且这将是实际使用的情况下,使用一个比其他?

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

推荐答案

在最近angular2的更新之一,@View被做了可选的。其所有属性搬进@Components。截至目前,@View是多余的。

In one of the recent updates of angular2, @View was made optional. All of its properties moved into @Components. As of now, @View is redundant.

我在我的应用程序,我只用组件的装饰。我觉得这种做法很容易编写和维护。

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

这篇关于Angular2组件模板VS查看模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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