Angular2是否使用Web组件? [英] Does Angular2 use Web Components?

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

问题描述

我已经听到了很多有关Angular第二次面世的讨论,并且似乎有很多很棒的事情,但是我知道Angular 1.0并没有针对Web组件的现成集成./p>

我已经阅读了一些有关Angular2的内容,并且不再使用指令.因此,我想知道这是否意味着Angular2是否将在不进行任何额外集成的情况下使用Polymer/HTML模板和其他Web组件?

解决方案

更新2

现在已支持 https://angular.io/guide/elements

更新

正在进行更改(目前仅是实验性)的工作-Angular元素 https://moduscreate.com/blog/angular-elements-ngcomponents-everywhere/

原始

Web组件可以在Angular2应用程序中使用,但是Angular2组件不能作为Web组件使用.

AFAIK没有使Angular2组件真正成为Web组件的短期计划.最初这是一个目标,但结果太复杂了.

在每个组件设置为ViewEncapsulation.Native的情况下,使用了阴影DOM,但在Angular2中效果不佳,因为浏览器缺少样式阴影DOM的功能. Polymer使用模拟的CSS变量和mixins,但Angular2尚未提供类似功能.

当前默认设置为ViewEncapsulation.Emulated,其中模拟了某些样式范围.

I've heard a lot of talk about the second coming of Angular and there seems to be a lot of fantastic things coming out of it but I know that Angular 1.0 does not have out of the box integration for Web Components.

I've read up some about Angular2 and that it no longer uses directives. So I was wondering if that means Angular2 is going to make use of Polymer/HTML Templates and other Web Components without any extra integration?

解决方案

update 2

That's now supported https://angular.io/guide/elements

update

There is an ongoing effort (currently only experimental) to change that - Angular elements https://moduscreate.com/blog/angular-elements-ngcomponents-everywhere/

original

Web components can be used in Angular2 applications, but Angular2 components can't be consumed as web components.

AFAIK there are no short-term plans to make Angular2 components actual web components. This was a goal at the beginning but turned out to be too complicated.

With the per component setting ViewEncapsulation.Native, shadow DOM is used, but that doesn't work too well in Angular2 because the browsers lack features to style the shadow DOM. Polymer uses emulated CSS variables and mixins but Angular2 doesn't yet provide anything like that.

Currently the default setting is ViewEncapsulation.Emulated where some style scoping is emulated.

这篇关于Angular2是否使用Web组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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