AngularJS和的WebSocketsAngularJS、WebSockets

2023-09-13 03:43:37 作者:彼岸花谢ㄨ她为君心碎ぺ

我想学习HTML5 / Node.js的/ EX preSS / MongoDB的/ AngularJS / WebSocket的事情,似乎让每个人都兴奋的现在。

I'm trying to learn the HTML5/Node.js/Express/MongoDB/AngularJS/Websocket thing that seems to have everyone excited right now.

由于轻微事与愿违,我其实有困难借鉴了每个技术实际上没有线(特别是EJS作为模板引擎)。 Javascript和HTML无处不在!

As a slight backfire, I'm actually having difficulty drawing lines on what each technology actually does (especially with ejs as a template engine). Javascript and HTML everywhere!

特别是,我无法分离由的WebSockets (或类似的东西提供的服务< A HREF =htt​​p://socket.io/相对=nofollow> socket.io )和 AngularJS 。他们似乎都尝试提供动力,而无需重新发送整个HTML页面。

Particularly, I'm having trouble separating the services provided by websockets (or something like socket.io), and AngularJS. They both seem to try to offer dynamism without having to resend an entire HTML page.

他们是相互替代?还是他们的目的不同?

Are they substitutes for one another? Or do they serve different purposes?

此外,这两种技术似乎朝着绕过前preSS'路由单页面的Web应用程序移动。那么,什么,是由前preSS使用的WebSockets / AngularJS当杠杆?这似乎是由实施例preSS的所提供的传统的路由代替只是改变视图在一个单页在AngularJS

Also, both these technologies seem to move towards single-page web applications that bypass Express' routing. What then, is leveraged by Express when using Websockets/AngularJS? It seems like the traditional routing offered by Express is substituted for just altering the view in a single-page in AngularJS

推荐答案

AngularJS是一个JavaScript库,做很多很多不同的东西。这些很多东西是最接近相关的WebSockets的一个是在香草的Javascript功能XmlHtt prequest顶部的一层。

AngularJS is a javascript library which does lots and lots of different things. The one of those many things which is closest related to WebSockets is the layer on top of the vanilla Javascript feature XmlHttpRequest.

两者XmlHtt prequest和的WebSockets是无需重新加载的网站交换与服务器数据的技术。所不同的是XmlHtt prequest(通常称为AJAX)如下请求 - 响应模型(客户机发出请求时,所述服务器的答案),而的WebSockets使用双向信道,其中客户端和服务器可以发送消息在任何时候。

Both XmlHttpRequest and WebSockets are techniques for exchanging data with a server without having to reload the website. The difference is that XmlHttpRequest (often referred to as AJAX) follows a request-response model (the client makes a request, the server answers), while WebSockets use a bidirectional channel where both the client and the server can send messages at any time.