node.js Angular js 和 Express js 之间的基本区别和相似之处是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18817630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:37:38  来源:igfitidea点击:

What are the basic differences and similarities between Angular js and Express js?

node.jsangularjs

提问by BluePython

So I am a bit confused in regards to the aim of Angular js vs Express js. From my understanding we use Node.js to serve Angular js but we are not entirely limited/forced to use Node.js for serving it. Express js on the other hand seems like it accomplishes something similar to the more traditional MVC framework.

所以我对 Angular js 与 Express js 的目标有点困惑。根据我的理解,我们使用 Node.js 来服务 Angular js,但我们并不完全受限/被迫使用 Node.js 来服务它。另一方面,Express js 似乎完成了类似于更传统的 MVC 框架的事情。

So is Angular Js a type of non-server-specific MVC framework? and does this limits Angular js backend server capabilities or ease of use?

那么 Angular Js 是一种非服务器特定的 MVC 框架吗?这是否会限制 Angular js 后端服务器的功能或易用性?

采纳答案by Thalaivar

Express

表达

Express is a web framework, inspired by the Ruby project 'Sinatra'. It's one of many web frameworks in Node

Express 是一个 Web 框架,其灵感来自 Ruby 项目“Sinatra”。它是 Node 中的众多 Web 框架之一

AngularJs

AngularJS

AngularJS is a MVC framework that defines numerous concepts to properly organize your web application. Your application is defined with modules that can depend from one to the others. It enhances HTML by attaching directives to your pages with new attributes or tags and expressions in order to define very powerful templates directly in your HTML. It also encapsulates the behavior of your application in controllers which are instanciated thanks to dependency injection.

AngularJS 是一个 MVC 框架,它定义了许多概念来正确组织您的 Web 应用程序。您的应用程序定义了可以相互依赖的模块。它通过将指令附加到具有新属性或标签和表达式的页面来增强 HTML,以便直接在 HTML 中定义非常强大的模板。它还将应用程序的行为封装在控制器中,这些控制器由于依赖注入而实例化。

AngularJS helps you structure and test your Javascript code very easily.

AngularJS 可以帮助您非常轻松地构建和测试您的 Javascript 代码。

Answer to your comment which i saw.

回答我看到的你的评论。

So would you say they are for different purposes client-side vs server-side implementations and therefore mutually exclusive or do you see a scenario in which one could use Angular Js, Expression js, and Node.js in the same application?

那么,您是说它们用于客户端和服务器端实现的不同目的,因此是互斥的,还是您看到可以在同一应用程序中使用 Angular Js、Expression js 和 Node.js 的场景?

Yes, they are for different purpose, but they both are MVC based framework. Yes, we can where you can use Angular router, views and controller for front end and use express as your base model to communicate with MongoDB or anyother Database. But yet again its your choice, as you can achieve everything without even bothering AnagularJs.

是的,它们用于不同的目的,但它们都是基于 MVC 的框架。是的,我们可以使用 Angular 路由器、视图和控制器作为前端,并使用 express 作为与 MongoDB 或任何其他数据库通信的基本模型。但这又是你的选择,因为你可以在不打扰 AnagularJs 的情况下实现一切。

Adding more.

添加更多

AngularJS is a beautiful client-side framework, highly testable, that combines tons of cool stuff such as MVC, dependency injection, data binding and much more. If you want to fully take advantage of the AngularJS features you may consider coding the server side using a RESTful approach. you can take advantage of their resource factory, which creates an abstraction of your server side RESTful API and makes server-side calls such as get, post, put, delete etc.

AngularJS 是一个漂亮的客户端框架,高度可测试,它结合了大量很酷的东西,比如 MVC、依赖注入、数据绑定等等。如果您想充分利用 AngularJS 的功能,您可以考虑使用 RESTful 方法对服务器端进行编码。您可以利用他们的资源工厂,它创建了服务器端 RESTful API 的抽象,并进行服务器端调用,例如 get、post、put、delete 等。

You can use AngularJS for defining your client-side behavior[Views and Controllers] and then write up the REST-Services which AngularJS client can interact with. The client runs on the web browser[AngularJS], and does asynchronous communication to the server. The server[ExpressJS] then retrieves and stores data for the client.

您可以使用 AngularJS 来定义您的客户端行为[视图和控制器],然后编写 AngularJS 客户端可以与之交互的 REST 服务。客户端运行在 Web 浏览器 [ AngularJS] 上,并与服务器进行异步通信。服务器[ ExpressJS] 然后为客户端检索和存储数据。

Maintaining a clear distinction between client and server makes the app easier to maintain and test.Adding to it, it all depends upon what you are trying to build and how best you can leverage both of them.

保持客户端和服务器之间的明确区别使应用程序更易于维护和测试。除此之外,这一切都取决于您尝试构建的内容以及如何最好地利用它们。

回答by coma

AngularJS is a javascript framework that runs on the client side, on the browser; it has a router, yes, but is only for the client side (in fact, it uses the hash as default).

AngularJS 是一个运行在客户端、浏览器上的 javascript 框架;它有一个路由器,是的,但仅用于客户端(实际上,它使用散列作为默认值)。

On the other hand, Node.js runs javascript without a browser, as a service and it can run frameworks like Express, dealing with HTTP and so on, making it a nice web server.

另一方面,Node.js 在没有浏览器的情况下运行 javascript,作为一种服务,它可以运行 Express 等框架,处理 HTTP 等,使其成为一个很好的 Web 服务器。

回答by Priya Ranjan Singh

Similarity is both are JavaScript frameworks which means you can write your server side and client side logic both in JavaScript if you were using them together.

相似之处在于两者都是 JavaScript 框架,这意味着如果您一起使用它们,您可以在 JavaScript 中编写服务器端和客户端逻辑。

Differences would be AngularJS is a client-side framework and Express is server-side framework.

不同之处在于 AngularJS 是客户端框架,而 Express 是服务器端框架。

Express can be used with any client-side framework and so can Angular be used with any server-side framework.

Express 可以与任何客户端框架一起使用,Angular 也可以与任何服务器端框架一起使用。