javascript - 服务页面,AngularJS 与 Node JS

标签 javascript angularjs node.js

所以我正在学习如何使用 Angular 和 Node JS 开发 Web,但我很困惑在哪里决定在哪里获取链接的 URL。我一直在阅读有关堆栈溢出的内容以及有关 Angular 和 Node 的随机教程,其中大多数只是解释路由处理程序(我现在已经弄清楚了)。一般来说,他们建议 Angular 应该处理所有页面路由,因此我认为它们也应该处理 URL 生成。但我在某处读到,Web 服务器( Node ?)应该生成 URL,而 Angular 应该只实现给定 URL 的路由处理。我不知道应该如何做(我想第一次就做对,这样我就不会重构大量代码)并且我对如何生成我需要的 URL 感到非常困惑。任何澄清将不胜感激。提前致谢!

最佳答案

对于单页面应用程序(Angulars 面包和黄油)来说,拥有一个服务器端路由处理程序是很常见的,无论用户登陆哪个页面,该处理程序都将提供完全相同的内容。此时,Angular 可以接管并计算出需要什么 Controller / View (通过路由处理程序)并将其显示在那里。

证实的答案 - 不在 Node 抱歉 - How to use ASP.NET MVC and AngularJS routing?

Now, when I navigate to http://www.example.com/Application1/view[x] it routes to the Application1 MVC controller, Index action, and then Angularjs takes over routes to the different views, all while having the HTML5 routing construct in the URL.

关于javascript - 服务页面,AngularJS 与 Node JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27025469/

相关文章:

node.js - 将 Node native 模块部署到 Azure 网站

javascript - mocha + mongodb 等待异步结果

javascript - D3v4 堆积条形图工具提示

javascript - 如何基于bower/npm自动生成Tern工程文件?

javascript - Angular 中的关注点分离 - 将函数传递给指令

node.js - 将文件从 React 上传到 S3 会出现 CORS 错误

javascript - 尝试使用 Node 获取sqlite数据

javascript - 单击后从按钮上移除焦点

angularjs - Angular 用户界面选择 : How to bind only selected value to ng-model

javascript - 单选按钮与 ng-repeat 的行为很奇怪