Jade模板和angularjs的实际使用 [英] Actual use of Jade template and angularjs

查看:28
本文介绍了Jade模板和angularjs的实际使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 nodejs 和 express 构建一个网站.如何使页面中的分区动态化?玉是用来做这个的吗?如果不是怎么办?angularjs 是做什么用的?请帮助我在谷歌上搜索了很多,但我无法清楚地了解它们的用法.

I am building a website using nodejs and express. How to make divisions in a page dynamic? Is Jade used for that? if not how to do it?what is angularjs used for? Please help i searched a lot on google and i couldn't get a clarity in the usage of them.

推荐答案

Jade 在服务器端的浏览器中创建 html.浏览器向 web-server 执行请求,web-server 执行 Jade,它将生成将发送到浏览器的 html.这种服务器端内容生成在过去大约 20 年中非常普遍,但是在构建富 Internet 应用程序时它有很多缺点.这主要与性能和客户端状态跟踪有关.

Jade creates the html used in the browser on the server-side. The browser executes a request to the web-server, the web-server executes Jade, which will generate the html that will be sent to the browser. This server-side content generation has been very common in the last ~20 years, but it has quite some cons when building rich internet application. Mostly this has to do with performance and client state tracking.

AngularJS 是一个类似于客户端 MVC/MVVM 的框架,用于构建所谓的 单页应用程序 (SPA),它允许您在客户端完成完整的用户界面流程、所有内容生成和状态跟踪.它甚至允许您构建离线应用程序.从开发人员的角度来看,这感觉更像是构建一个客户端知道用户界面状态的桌面应用程序.从用户的角度来看,由于 UI 都是在本地生成的,因此网站的响应会更加流畅和快速.

AngularJS is a client-side MVC/MVVM like framework to build so called Single Page Applications (SPA), which allows you to have the complete user interface flow, all content generation and state tracking to be done at the client side. It even allows you to build offline applications. From the developer point of view this feels much more like building a desktop application where the client knows the state of the user interface. From the user point of the view the website will respond much smoother and snappier because the UI is all generated locally.

注意:SPA不是意味着您的网站中只能有一个页面.这是一个技术术语,浏览器下载一个页面 (~/index.html),其中包含完整或部分的 Web 应用程序.从技术上讲,用户永远不会离开这个页面,但内容(页面)会动态地从这个占位符页面换入和换出.

Note: SPA does not mean that you can only have one page in your website. It's a technical term where the browser downloads one page (~/index.html), which contains the complete or partial web application. The user technically never leaves this page, but the content (pages) is dynamically swapped in and out from this placeholder page.

SPA 提供数据的最常见方式是通过 RESTful 网络服务.AngularJS 为 REST 提供了内置支持.

To most common way to provide data to a SPA is via RESTful web services. AngularJS comes with builtin support for REST.

一些开发人员将服务器端内容生成技术与 AngularJS 相结合,但实际上并没有真正的需要.

Some developers combine server-side content generation techniques with AngularJS, but there's actually no real need for this.

这篇关于Jade模板和angularjs的实际使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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