Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
310 views
in Technique[技术] by (71.8m points)

javascript - AngularJS仅适用于单页面应用程序(SPA)吗?(Is AngularJS just for single-page applications (SPAs)?)

We are looking at options to build the front end of an application we are creating and are trying to evaluate a tool that will work for us and give us the best platform to move forward.(我们正在寻找构建我们正在创建的应用程序前端的选项,并且正在尝试评估一个对我们有用的工具,并为我们提供最佳的平台。)

This is a Node.js project.(这是一个Node.js项目。)

Our initial plan was to use Express and go down that route, but we decided that before we kick off this stage it might be best to review what is out there.(我们最初的计划是使用Express并沿着这条路走下去,但我们决定在开始这个阶段之前,最好回顾一下那里的情况。) Our application has several areas which we don't believe fit the single-page model in that they are related from an application perspective, but not from a view one.(我们的应用程序有几个我们认为不适合单页模型的领域,因为它们从应用程序的角度来看是相关的,而不是从视图中看。)

We have seen a few of the frameworks we could use to build out the client like Backbone.js , Meteor , etc. and also AngularJS.(我们已经看到了一些可以用来构建客户端的框架,比如Backbone.jsMeteor等,还有AngularJS。)

This may be a fairly obvious question, but we cannot seem to decipher if AngularJS is purely for single-page application or it can be used for multi-page applications like Express for instance.(这可能是一个相当明显的问题,但是如果AngularJS纯粹用于单页面应用程序,或者它可以用于Express等多页面应用程序,我们似乎无法破译。)


UPDATE 17 July 2013 Just to keep people in the loop, I will be updating this question as we go through the process.(更新2013年7月17日为了让人们保持在循环中,我将在整个过程中更新这个问题。)

We are going to build everything together for now, and we will see how well that performs.(我们现在要一起构建所有内容,我们将看到它的表现如何。) We have reached out to a few people who are more qualified with AngularJS than us and posed the question regarding splitting up larger applications that share context, but may be too large working on a single page.(我们已经联系了一些比我们更有资格使用AngularJS的人,并且提出了关于拆分共享上下文的更大应用程序的问题,但是在单个页面上工作可能太大。)

The consensus was that we could serve multiple static pages and create AngularJS applications that work with only those pages, effectively creating a collection of SPA and linking those applications together using standard linking.(我们的共识是,我们可以提供多个静态页面并创建仅与这些页面一起使用的AngularJS应用程序,有效地创建SPA集合并使用标准链接将这些应用程序链接在一起。)

Now our use case is very specific as our solution has several applications, and as I said we are going to try the single code base first and optimise from there.(现在我们的用例非常具体,因为我们的解决方案有几个应用程序,正如我所说,我们将首先尝试单个代码库并从那里进行优化。)

UPDATE 18 June 2016 The project fell of a cliff, so we never got round to getting too much done.(更新2016年6月18日该项目陷入悬崖,所以我们从来没有完成过多的工作。)

We have picked it up again recently, but are no longer using angular and are using React instead.(我们最近再次提起它,但不再使用角度而是使用React。) We are still using the architecture outlined in the previous update, where we use express and self contain apps, so for example, we have a /chat route in express that serves up our React chat app, we have another route /projects that serves up the projects app and so on.(我们仍然使用上一次更新中概述的体系结构,我们使用快速和自包含应用程序,例如,我们在快递中有一条/chat路线,用于提供我们的React聊天应用程序,我们有另一条路线/projects提供服务项目应用程序等。) The way we are kinda looking at it is each app is an aggregate root in terms of its feature set, it needs to be able to standalone for it to be considered an app in itself.(我们有点看待它的方式是每个应用程序在其功能集方面是一个聚合根,它需要能够独立,因为它本身被视为一个应用程序。) Technically, all the information is out there, its just basic express and whatever flavour of client side app building goodness you want to use.(从技术上讲,所有的信息都在那里,它只是基本的表达,以及你想要使用的客户端应用程序构建良好的任何风格。)   ask by Modika translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Not at all.(一点也不。)

You can use Angular to build a variety of apps.(您可以使用Angular构建各种应用程序。) Client-side routing is just a small piece of that.(客户端路由只是其中的一小部分。)

You have a large list of features that will benefit you outside of client-side routing:(您有一大堆功能,可以在客户端路由之外使您受益:)

  • two-way binding(双向绑定)
  • templating(模板)
  • currency formatting(货币格式)
  • pluralization(多元化)
  • reusable controls(可重复使用的控件)
  • RESTful api handling(RESTful api处理)
  • AJAX handling(AJAX处理)
  • modularization(模块化)
  • dependency injection(依赖注入)

It's crazy to think that all of that "could only be used in a single page app".(认为所有这些“只能用于单页应用程序”真是太疯狂了。)

Of course not.. that's like saying "Jquery is only for projects with animations".(当然不是......就像说“Jquery仅适用于带动画的项目”。)

If it fits your project, use it.(如果它适合您的项目,请使用它。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...