如何角JS涉及到谷歌关闭? [英] How does Angular JS relate to Google Closure?

查看:212
本文介绍了如何角JS涉及到谷歌关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在的 AngularJS 被释放我想知道这个项目如何与其它通用的JavaScript框架/从谷歌的工具,适合一起的关闭

Now that AngularJS 1.0 is released I am wondering how this project fits together with the other general-purpose JavaScript framework / tool from Google, Closure.

我只看到这两种技术的基本描述(和阅读有关的书封的一半),所以我没有直接的经验,但是这是它的外观对我说:

I have only seen basic description of those two technologies (and read about a half of the book on Closure) so I have no direct experience but this is how it looks to me:


  • 封闭是一组可单独使用的技术。我觉得可能是最吸引人的是:

    • 关闭编译器这似乎在一定意义上,它警告说,不要典型的问题,以修复的JavaScript,提供了一些编译时检查(不是所有的人都喜欢这一点,但可能大部分谷歌开发人员做的,我做太多)。当然,这是很好的结果code是更小,更高效。

    • 再就是封库,我喜欢,例如一些地区在内置类型( ArrayLike 等),基于类的系统,事件机制,DOM抽象等等。我不知道抽象但如果我喜欢的GUI库或没有(似乎是相当复杂的,我真的没有时间去研究它尚未)。

    • 再就是,我不认为我会发现有用的,例如一些功能模板

    • Closure is a set of technologies that can be used separately. What I find probably the most appealing is:
      • Closure Compiler which seems to "fix JavaScript" in a sense that it warns against typical issues, provides some compile-time checks (not all people like this but probably most Google developers do, and I do too). And of course it's nice that the resulting code is smaller and more efficient.
      • Then there are some parts of Closure Library that I like, e.g. abstractions over built-in types (ArrayLike etc.), class-based system, eventing mechanism, DOM abstractions etc. I'm not sure yet if I like the GUI library or not (seems to be quite complex and I didn't really have time to study it yet).
      • Then there are some features that I don't think I would find that useful, e.g. Templates.

      所以这两种技术似乎是针对完全不同的抽象层次,所以我首先想到的是,他们能一起使用?关闭提供低级别的编译器和浏览器的抽象,同时提供角应用层服务和结构?就有意义,它会很好地协同工作?

      So these two technologies seem to be aimed at quite a different level of abstraction so my first thought was, can they be used together? Closure providing low-level compiler and browser abstractions while Angular providing application-level services and structure? Would it make sense and would it work well together?

      推荐答案

      只有谷歌的项目,我所知道的使用AngularJS是DoubleClick的团队。 (presentation)从本质上讲,他们仍然使用谷歌关闭图书馆的一切,但UI建筑。还要注意的是,他们使用谷歌关闭编译器,但是这几乎是一个给定的,没有人只使用图书馆没有编译器。

      The only Google project I'm aware of that uses AngularJS is the DoubleClick team. (presentation) Essentially, they still use Google Closure Library for everything but the UI building. Also note that they use Google Closure Compiler, but that's almost a given, "nobody" uses only the Library without the Compiler.

      谷歌关闭图书馆配备了在其 goog.ui 命名空间的UI框架。该框架几乎每一个方式相比在像Android的,iOS的,Swing和QT非Web UI框架。他们有我喜欢叫类固醇DOM元素的事情, goog.ui.Component ,其中有很多伟大的生命周期机制,垃圾收集和事件监听等等。你有一个像 goog.ui.Control 的东西,这是 goog.ui.Component 的一个子类,并处理用户在一个非常有趣的方式互动。它可以让你插上渲染器,例如,所以你可以改变一个<按钮> < A> 在不改变任何您的其他逻辑,除了实际的渲染。

      Google Closure Library comes with a UI framework in its goog.ui namespace. This framework compares in almost every way to non-web UI frameworks like Android, iOS, Swing and QT. They have a thing I like to call DOM elements on steroids, goog.ui.Component, which has lots of great life cycle mechanisms for garbage collection and event listening and more. You have things like goog.ui.Control, which is a subclass of goog.ui.Component, and handles user interaction in a very interesting way. It lets you plug renderers, for example, so you can change a <button> to an <a> without changing any of your other logic except the actual rendering.

      类和子类说起,谷歌关闭图书馆也有这个。您不必使用内置其中,重要的是你以某种方式调用你的方法了超的雏形。例如,您可以使用类系统的CoffeeScript,谷歌关闭图书馆不关心。

      Speaking of classes and subclasses, Google Closure Library also has this. You don't have to use the built-in one, the important part is that you somehow call the prototype of the "superclass" in your methods. You can for example use the class system in CoffeeScript, Google Closure Library doesn't care.

      DoubleClick小组选择了AngularJS的原因是<一个href=\"https://groups.google.com/d/topic/closure-library-discuss/C87SV9f0p6o/discussion\">apparently因为数据绑定功能AngularJS的主要提供。没有什么内置在谷歌图书馆关闭自动更新的用户界面时,数据的变化。

      The reason the DoubleClick team chose AngularJS was apparently largely because of the data binding features AngularJS provides. There's nothing built-in in Google Closure Library to automatically update the UI when data changes.

      总结一下,谷歌关闭是huuuuge兽,AngularJS可以取代谷歌关闭图书馆 goog.ui 部分。

      So to summarize, Google Closure is a huuuuge beast, and AngularJS can replace the goog.ui part of the Google Closure Library.

      这篇关于如何角JS涉及到谷歌关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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