Google AngularJS 框架 - 值得冒险吗?

发布于 2024-12-08 01:57:57 字数 393 浏览 1 评论 0原文

我被要求为我们的一位客户构建一个小型 Web 应用程序,我认为这可能是尝试使用不同框架来构建 Web 应用程序的好机会。我们构建的大多数应用程序都基于 asp.net Web 表单,我们尚未在 MVC 架构中做任何事情,但我渴望开始使用正确的工具以更结构化的方式构建 Web 应用程序。

我一直在研究像 asp.net MVC 之类的东西,它们看起来相当不错,但我想知道使用像 Google AngularJS 框架这样的东西有什么可说的。

如果可能的话,我仍然希望能够使用 C# 编写我的服务器端代码,并且我还没有对 AngularJS 进行足够的研究,不知道这是否可能,尽管我假设我可以使用 Web 服务。

有没有人有使用 AngularJS 开发应用程序的经验,如果有的话,感觉如何?您能为我指出一些教程的正确方向吗?

I have been asked to build a small web application for one of our clients and think it might be a good opportunity to try out a different framework for building web applications. Most of the applications we build are based on asp.net web forms and we have no yet done anything in an MVC architecture but I am eager to start building web applications in a more structured manner with the right tools.

I have been researching things like asp.net MVC and the likes which look quite good but I am wondering is there anything to be said for using something like the Google AngularJS Framework.

If possible I would still like to be able to write my server side code using c# and I have not researched AngularJS enough to know if this is even possible, although I assume I could use web services.

Has anyone had any experience with developing an app using AngularJS and if so, how was it and can you point me in the right direction for some tutorials?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

风渺 2024-12-15 01:57:57

过去几个月我们一直在 AngularJS 中开发 Swing 胖客户端应用程序的端口,我认为值得推荐。就学习资源而言,请查看官方项目网站(并务必阅读教程)和邮件列表(作者非常有帮助)。

好东西:

  • 良好的可测试性,
  • 双向数据绑定是一个非常强大的功能,一旦你“掌握了它”,它就会非常有帮助,在
  • 我看来,AngularJS 模板比使用数据属性或“特殊”CSS 类要脆弱得多。标记做某事的元素,
  • 它大大减少了使用 jquery 插件的需要,因为在 AngularJS 中实现该功能非常容易(比如树、选项卡、手风琴等)。

坏处是:

  • 学习曲线似乎相当陡峭(我没有t 有这是一个很大的问题,但我看到有些人在努力解决这个问题)
  • AngularJS 中的验证暂时很糟糕(一个新的实现正在路上)
  • 并不是所有的库/jquery 插件都能很好地与 Angular 配合使用,通常你必须包装它们
  • API 仍在完善中,因此预计会有重大变化(不过,对于频繁发布和非常好的变更日志来说,这不是一个大问题)
  • 性能还可以,直到页面上有数千个绑定 - 大多数时候这不是一个限制,但有在这种情况下,这可能是 问题。

一些提示(如果您决定学习 AngularJS):

  • 有些人确实过度使用小部件。根据我的经验,最好使用 HTML“partials”+ 服务,并且只偶尔使用小部件。
  • 阅读该库的源代码 - 这是学习有关
  • 服务/控制器中的角度无 DOM 操作的
  • 最佳位置如果您使用 css 类绑定到事件,那么您就做错了

We have been developing a port of a Swing fat-client application in AngularJS for the last couple of months and I think it is worth recommending. As far as learning resources go, check out the official project site (and be sure to read the tutorial) and the mailing list (the authors are very helpful).

The good stuff:

  • great testability
  • the two-way data binding is a very powerful feature, and it can be extremely helpful once you "get it"
  • IMO the AngularJS templates are much less brittle than using data- attributes or "special" CSS classes to mark elements that do something
  • it greatly reduces the need for using jquery plugins, because implementing that functionality in AngularJS is very easy (stuff like trees, tabs, accordions, etc.)

The bad stuff:

  • the learning curve seems pretty steep (I didn't have much of a problem, but I've seen some people struggle with it)
  • validations in AngularJS suck for the time being (a new implementation is on the way)
  • not all libraries/jquery plugins play nicely with Angular and usually you have to wrap them
  • the API is still being polished, so expect breaking changes (not a big problem with frequent releases and very good changelog, though)
  • performance is OK up until several thousand bindings on a page - most of the time this is not a limitation, but there are cases when this could be a problem.

Some pointers (if you ever decide to learn AngularJS):

  • some people really overuse widgets. In my experience, it's much better to use HTML "partials" + services, and only use widgets sporadically.
  • read source code of the library - it's the best place to learn stuff about angular
  • no DOM manipulation in services/controllers
  • if you use css classes to bind to events, you are doing it wrong
擦肩而过的背影 2024-12-15 01:57:57

+1 @psycho 的回答

AngularJS 是客户端框架,因此您可以在服务器上使用任何语言。它的设计目的是与 jQuery 很好地配合使用,重点是测试...

以下是一些您可能会发现有用的资源:

一些示例应用程序:

SenchaTouch 适配器:https://github.com/tigbro/sencha-touch-angular-adapter

适配器jQ Mobile:https://github.com/tigbro/jquery-mobile-angular-adapter< /a>

欢迎在邮件列表上提出任何问题!

我们仍然在Beta 版,但 Google 已经有几个由 AngularJS 提供支持的内部应用程序。


更新(2012 年 7 月 26 日):

AngularJS v1.0 已发布。

对于一些公共 AngularJS 支持的应用程序,请查看 http://builtwith.angularjs.org

+1 @psycho's answer

AngularJS is client-side framework, so you can use any language on the server. It's designed to work well together with jQuery, with big emphasis on testing...

Here are some resources you might find useful:

Some example apps:

Adapter for SenchaTouch: https://github.com/tigbro/sencha-touch-angular-adapter

Adapter for jQ Mobile: https://github.com/tigbro/jquery-mobile-angular-adapter

Feel free to ask any question on mailing list !

We are still in beta, but there are already several internal apps at Google, powered by AngularJS.


UPDATE (26th July 2012):

AngularJS v1.0 has been released.

For some public AngularJS-powered apps, check out http://builtwith.angularjs.org

ゝ杯具 2024-12-15 01:57:57

恕我直言,为客户开发一些他们可能难以支持的东西是不专业的。您必须记住,您的客户将很难聘请经验丰富的 Angular 专业人员,或培训自己的人员来攀登“陡峭的学习曲线”。另外,到目前为止,文档还不是那么好。您能否在几分钟内轻松回答以下问题:“如何将闪亮的 Angular 应用程序连接到客户的数据库?”您的客户在未来的某个时候能否轻松获取一些现有代码并使其适应他们未来潜在的需求?说实话。

将普通的老式可靠 LAMP 开发与 Angular 进行比较。对于“小型网络应用程序”,我真的相信专业人士应该为他的客户提供可维护且简单的东西。

这并不是说 Angular 不酷、不性感等等。但是,除了最新的框架时尚之外,您还需要考虑客户未来的可维护性。我的建议是小心行事。首先使用 Angular 构建您自己的网站,然后看看您的想法,然后再将您出色的新技能授予一些值得信赖的客户。

IMHO developing something for a client which they may have difficulty supporting is unprofessional. You have to bear in mind that it will be difficult for your client to hire experienced Angular professionals, or train their own people to climb that "steep learning curve". Also, so far the documentation is not that great. Can you easily, in a few moments, answer the question, "How can I connect my shiny Angular app to my client's database?" Can your client sometime in the future easily grab some existing code and adapt it to their potential future needs? Be honest.

Compare plain old reliable LAMP development to Angular. For a "small web application" I really believe that a professional should give his client something maintainable and simple.

It's not to say that Angular isn't cool and sexy etc etc. But you have your client's future maintainability to think about in addition to the latest framework fad. Tread lightly would be my recommendation. Build your own website with Angular first and see what you think before you bestow your fabulous new skills on some trusting client.

百变从容 2024-12-15 01:57:57

我记得几个月前读过这个帖子,心里有同样的问题,我们决定继续使用 AngularJS,这是我们在这个项目上做出的最佳决定。

我们使用 AngularJS + ASP.NET MVC4 REST WebAPI。

最有可能的是,在有了这样一个不错的客户端 Javascript MVC 框架之后,您只需要 REST API 层与服务器端的业务逻辑层交互,而服务器端不需要 MVC(ASP.NET MVC/Spring/Structs 会感觉像是旧的记忆)。

您会发现 Angular-UI 很好的附加组件(esp ng-grid)

在我们的项目完成后不久,我们可能会放置一些我们为开源世界编写的指令。

I remember reading this SO thread couple of months back with same question in my mind, and we decided to go ahead with AngularJS, and the best decision we made on this project yet.

We are using AngularJS + ASP.NET MVC4 REST WebAPI.

Most probalbly after such a nice client side Javascript MVC framework, you would only need REST API layer interacting with Business Logic Layer at server side, and no MVC at server Side (ASP.NET MVC/Spring/Structs would feel like old memories).

You will find Angular-UI good add-on (esp ng-grid)

Soon after our project finishes, we might put some of our directive we wrote for open source world.

七月上 2024-12-15 01:57:57

几个月来我一直在研究 AngularJS 的优点,以将其用作我正在创建的产品的核心框架。
AJS 有很多方面值得学习。是的,有一点学习曲线,但这是非常值得的,特别是如果您希望对客户端功能有更多的控制。

JQuery 在运行时操作 DOM,而 AJS 将自身置于 JS 渲染生命周期内。这允许您通过创建 HTML 元素和属性来教授 DOM 新技巧。这是非常非常强大的。因为您可以做的是根据您的目的和需要引入新的元素行为。在 AJS 中,这些自定义 HTML 属性/元素称为指令。凭借制定自己的指令的能力,您能够构建当前 HTML 所不具备的功能,从而推出可在现在和未来的所有现代浏览器上运行的功能。在诱导新行为的众多方法中,AJS 似乎是人们可以采取的最安全的方向,因为他们选择了实施它的方式。

AJS 中的性能比 JQuery 有巨大的提升。

我喜欢双向数据绑定的简单性,以及客户端 MVC 模式中的关注点分离,如上所述,这提供了很好的可测试性。范围对象是视图(HTML)、模型(您的数据)和自定义控制器之间的粘合剂。范围提供对父属性的访问,并且可以在同级级别进行隔离,这对于某些可重用模板非常重要。

可以在您的应用程序中创建和重用模板,其中可以包含 0 个或多个自定义指令。

我一直在使用 PRISM 和 MEF 等框架,但我发现 AJS 具有这些 .NET 框架中存在的大部分相同功能,但占用空间为 29K。有传言称他们正在研究延迟加载,如果提供的话将提供一些非常有趣的 LOB 类型功能。

有许多为 AJS 构建的 UI 框架,但只要付出一些努力,您就可以根据需要包装任何第 3 方控制库。诀窍是确保当这些第 3 方控件引起更改时,您确保使用其 apply 方法正确通知 AJS。

如果您在 VS 2012 中将 AJS 与 MS TypeScript 结合起来,它就提供了管理和构建一些非常令人印象深刻的项目的能力,这对于那些更熟悉 VS 中的项目的人来说将非常有用。

考虑 AJS 还有很多其他原因,但如果您正在考虑 KnockOut 等框架,我强烈推荐 AJS,无论它的学习曲线如何。 Knockout是一个库,AJS是一个框架。

I have been researching the merits of AngularJS for many months to utilize as a core framework for product I am creating.
There are many aspects of AJS that make it worth while to learn. Yes there is a bit of a learning curve but its well worth it, especially if you wish to have more control on client side capability.

JQuery manipulates the DOM at run time, whereas AJS situates itself within the JS rendering lifecycle. This allows you to teach the DOM new tricks by creating your HTML Elements and Attributes. This is very, very powerful. As what you are able to do is introduce new Element behaviors for whatever your purpose and need. In AJS these custom HTML Attributes/Elements are called Directives. With the ability to craft your own Directives, you are able to build functionality that the current HTML doesn't have, pushing out capabilities that will run on all modern browsers now and into the future. Of the many approaches to inducing new behavior, AJS appears to be the safest direction one could take due to how they have chosen to implement it.

There is a huge performance gain over JQuery in AJS.

I love the simplicity of the two-way data binding, and the separation of concerns in their client side MVC pattern, which as pointed out above provide great testability. There scope object is the glue between the View (HTML), the Model (your Data) and your custom Controllers. The scope provides access to parent attributes and can be isolated at the sibling level, which is important for some reusable templates.

Templates can created and reused across your application which can contain 0 or more custom directives.

I have been using frameworks such as PRISM and MEF but I am finding that AJS has most of the same features that exist in these .NET frameworks but in a 29K footprint. There is rumors that they are working on lazy-loading which if provided will provide for some very interesting LOB type capabilities.

There are a number of UI frameworks that are being built for AJS but you can wrap any 3rd party control lib as needed, given a bit of effort. The trick is to ensure that when these 3rd party controls have changes induced, that you ensure AJS is properly notified using their apply method.

If you combine AJS with MS TypeScript within VS 2012, it provides the ability to manage and build some very impressive projects which will work well for those who are more comfortable with projects within VS.

There are a ton of other reasons to look at AJS, but if you are considering frameworks such as KnockOut I'd highly recommend AJS instead, regardless of it's perceived learning curve. Knockout is a library, AJS is a framework.

晨光如昨 2024-12-15 01:57:57

到目前为止,我认为 Google 的 Angular 很棒。特别是数据绑定和依赖注入。

对于其他js框架,还有knockout.js、backbone.js等。
这里有一些帖子:
backbone.js 和/或淘汰赛中的 angular.js 示例.js

So far i think Google's Angular is great. Particular like the databinding and dependency injection.

For other js framework, there are knockout.js , backbone.js etc.
here are some posts:
angular.js example in backbone.js and/or knockout.js

安静被遗忘 2024-12-15 01:57:57

我意识到这篇文章已经很旧了,而且你还没有使用 Angular,但我和你有相似的背景,而且在问这个问题时我和你的观点是一样的。

因此,为了未来访问者的利益,我发现一些有用的“风险”和资源链接...

  • 正如许多人已经提到的,Angular 的学习曲线非常陡峭“不仅是我,还有同事我认为开发人员非常聪明,但在一些基本概念上遇到了困难” AngularJS 太棒了......而且很难< /a> (链接也有一些您要求的很好的教程链接),版本 2 的内容是 看起来更像 java,这对于您的 C# 背景来说不会有问题,在我看来,如果没有详细的注释等,指令就很难理解。
  • 在某些情况下,角度性能可能很差,尤其是在大量元素上使用 ng-repeat 时 考虑 AngularJS 中的速度和缓慢Scaylr 的经验。其他人提到,性能确实会降低大约 2000 个绑定元素,但这通常会引起争论,认为任何具有超过这么多元素的应用程序可能都不是一个好的应用程序。但如果您有需要许多绑定对象的合法用例,请记住这一点。
  • Angular 很受欢迎就贡献者而言,但在 生产使用。寻找 Angular 开发人员可能很困难,而 jQuery 或其他转换的开发人员则需要应对“陡峭的学习曲线”。
  • 因为 Angular 还很年轻,所以你不能保证它会获得足够的吸引力,让你的新 Angular 技能可以使用,并且你的新应用程序不会很快成为遗留代码。
  • 在 v1.2 中,Angular 不支持 IE7 及更低版本和 v1.3 将下降IE8。对于>=IE9,您需要遵循一些特殊的编码实践
  • 您可能习惯使用的许多 JavaScript 小部件、插件和库在不进行大量修改的情况下无法在 Angular 中正确使用,人们经常建议 无论如何都要用 Angular 重写你的组件
  • 2014 年 3 月更新:在尝试构建一个不平凡的功能密集的单页应用程序 2 个月后:Angular 有很多版本,很难说哪个是最好的或最稳定的。这将取决于您用它编码的内容。我发现一些 Angular 错误可以通过升级到更高版本来修复,而其他错误可以通过回归到早期版本来修复。我从来没有像这样使用 jQuery 进行版本购买。
  • 2014 年 5 月更新:年轻、破损的工具。 Batarang 非常棒,直到它不起作用。在他们解决这个问题之前我无法相信它。

最后,我找到了学习这些东西的三个最佳资源

I realise this post is old and you haven't gone with Angular, but I have a similar background to you, and I'm at the same point as you when asking the question.

So for the benefit of future visitors, some of the "risks" and links to resources I've found useful...

  • As many have already mentioned, Angular can have a very steep learning curve "Not only me, but co-workers that I consider highly smart developers, have struggled with some of the basic concepts" AngularJS is amazing... and hard as hell (link also has some good tutorial links which you asked for), and the version 2 stuff is looking more like java, which wouldn't have been a problem with your C# background, in my opinion Directives are hard enough to understand without verbose annotations and so on.
  • Angular performance can be poor in some cases, especially when using ng-repeat on a large number of elements Considering Speed and Slowness in AngularJS and Scaylr's experience. Other's have mentioned that performance really degrades over ~2000 bound elements, but that's usually met with arguments about how any app with more than that many elements probably isn't a good app. Keep it in mind though if you have legitimate use cases which call for many bound objects.
  • Angular is popular in terms of contributors, but ranks way way behind, say, jQuery in terms of production usage. Finding Angular developers might be tough, and jQuery or other developers converting have that "steep learning curve" to deal with.
  • Because Angular is young, you have no guarantee that it'll gain enough traction for your new Angular skills to be employable, and your new application not to quickly become legacy code
  • In v1.2 Angular doesn't support IE7 and below and v1.3 will drop IE8. For >=IE9, you need to follow some special coding practices.
  • The many javascript widgets, plugins and libraries which you might be used to using can't be used properly with Angular without heavy modification and people often suggest to re-write your component in Angular anyway.
  • UPDATE March 2014: after 2 months attempting to build a non-trivial densely functional one page app: There are many versions of Angular, and it's hard to say which is the best or most stable. It will depend on what you're coding with it. I'm finding some bugs Angular that are fixed by upgrading to a later version and others fixed by regressing to an earlier one. I've never had to go version shopping like this with jQuery.
  • UPDATE May 2014: Young, broken tools. Batarang is great until it doesn't work. I can't trust it until they fix this one.

And finally, the three best resources I've found for learning this stuff

生生漫 2024-12-15 01:57:57

我对此表示同意,并查看 John Papa 的 hottowel 实现作为一种实现方式。

I would say yes to this and check out John Papa's hottowel implementation as a way to do it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文