使用标准的Web技术角度更换 [英] Replacing angular with standard web technologies

查看:153
本文介绍了使用标准的Web技术角度更换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在这对为将1.5年内出货产品的最新浏览器中使用ECMA 6奢侈的项目。所以我们认为,为什么不使用Web组件现在角2不可用(这将是ECMA 6)。虽然我们是在它,我们可以完全不必回到石器时代取代角?

I'm working on a project which has the luxury of using ECMA 6 on the latest browsers for a product that will be shipped in 1.5 years. So we thought why not use Web Components now that Angular 2 isn't available (which is going to be ECMA 6). And while we are at it, can we replace Angular altogether without having to go back to stone age?

有就是这个网站名为 youmightnotneedjquery.com 这基本上是关于浏览器如何真正现代有无的大部分东西, jQuery的是传统上用于。我很感兴趣地看到类似的东西了棱角分明。

There's this site called youmightnotneedjquery.com which is basically about how modern browsers actually have most of the stuff that jQuery was traditionally used for. I'm interested to see something like that for Angular.

我们主要采用四个角度的功能。我有哪些更换他们的选择?

We mainly use four Angular features. What are my options for replacing them?


  • 角指令 - > Web组件

  • 角模块 - > ECMA 6个模块(不完全一样的东西)

  • 角路线 - > ???

  • 角2路数据绑定 - > ???

  • Angular Directives --> Web Components
  • Angular Modules --> ECMA 6 Modules (not exactly the same thing)
  • Angular Routes --> ???
  • Angular 2-way databinding --> ???

PS。我们不希望更换角类似像骨干或灰烬的东西。我们希望与标准的Web技术来取代它,但如果我们不得不使用小工具,填补了国内空白,我们会考虑的。

PS. We don't want to replace Angular with something similar like Backbone or Ember. We want to replace it with standard web technologies but if we have to use small tools to fill the gap, we'll consider it.

推荐答案

我在近3几周研究和原来很多人都在思考另一种角度花了很大的变化路径之后。幸运的是,upcomming W3C Web组件标准实际上有我们所需要的,它现在的作品与来自聚合物项目 polyfills。因此,要回答这个问题:

I've been researching in the past 3 weeks and turns out many people are thinking about an alternative after Angular took a drastic change path. Fortunately the upcomming W3C Web Components standard actually has all we need and it works right now with polyfills from the Polymer project. So to answer the question:

  • Angular Directives --> Web Components use the polyfill until all browsers support it.
  • Angular Modules --> ECMA 6 Modules part of the problem is solved with HTML imports. But you can also use Traceur until the browsers support it.
  • Angular Routes --> There's a component for that™ use <app-router>.
  • Angular 2-way databinding --> Polymer adds a "magic" layer on top of the plain standard web components. This includes many features including data-binding.

如果你想知道有关以减少HTTP请求的数量,看一看的阿迪·奥斯马尼的一篇关于硫化。剧透:你可能不与即将推出的HTTP需要2优化

If you're wondering about the build process for concatenating files in order to reduce the number of HTTP requests, take a look at Addy Osmani's post about Vulcanize. Spoiler: you may not need it with the upcoming HTTP 2 optimizations.

许多角的项目中使用Twitter的引导的布局。聚合物可以做到这一点,再加上它与谷歌的纸业元素(完全可选的,但极好真棒很好地发挥)。

Many Angular projects use Twitter Bootstrap for the layout. Polymer can do that plus it plays nicely with Google's Paper elements (totally optional but superbly awesome).

如果你想使自己熟悉一般的网络组件,这里是一堆漂亮的文章: http://webcomponents.org/articles /

If you want to make yourself familiar with web components in general, here is a bunch of nice articles: http://webcomponents.org/articles/

这里是一个丰富的Web组件: http://customelements.io/ 我不知道它是否将是一个新的NPM,但列表中的组件是pretty IM pressive和成长。

And here is a wealth of web components: http://customelements.io/ I don't know if it's going to be a new NPM, but the list components is pretty impressive and growing.

这是比较复杂的,露出一个API,角分量。人们纷纷拿出从<一个各种方法href=\"http://stackoverflow.com/questions/18533370/how-to-expose-a-public-api-from-a-directive-that-is-a-reusable-component\">link功能来发射事件的。在 Web组件,但是,它真的很容易,使您的组件与外部世界的确互动你揭露API和事件不会从标准的HTML标记像很多不同的&LT;音频方式&gt;

It's relatively complicated to expose an API for an Angular component. People have come up with all sorts of methods from link function to emitting events. In Web Components, however, it's really easy to make your component interact with the world outside and indeed the API and events you expose aren't much different from standard HTML tags like <audio>.

就像,则可以使用聚合物镖为好。

Just like Angular, you can use Polymer with Dart as well.

总体来说,我看不出有任何理由使用角度,除非:

Overall, I don't see any reason to use Angular except if:


  1. 您有一个角巨源$ C ​​$ C的投资和不想端口一切标准的网络。 (角2.0将取消precate您code无论如何,所以你坚持角1。*)

  2. 您的团队是懒得学习新的技术(在这种情况下,网络可能不是这种态度的合适平台反正)。

角是好的它在做什么,并有自己的炒作周期。 Web组件解决了许多问题角度试图解决的问题。大概角有作用的概念,为Web组件的证明。但现在是时候继续前进。网络正在重塑自我每天和它的必然移动别人的奶酪

Angular was good for what it was doing and had its own Hype cycle. Web components solve many of the issues Angular was trying to address. Probably Angular had a role as a proof of concept for the Web components. But now it's time to move on. Web is reinventing itself everyday and it's inevitable to moves someone's cheese.

我不是说的聚合物是最终的一切问题的答案的。充其量它的另一个角度,这将呈现几年没用,但现在它的学习和使用它的好时机。该 W3C 标准 中的容易不过,和聚合物往往是更接近它们。

I'm not saying that Polymer is the ultimate answer to everything. At best it's another Angular which will render useless in a couple of years, but now it's a good time to learn and use it. The W3C standards don't die easily though, and Polymer tends to be much closer to them.

有针对贸易的元素; 是新的还有针对与贸易的应用;

这篇关于使用标准的Web技术角度更换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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