为什么Angular在其教程中需要服务器? [英] Why does Angular require a server in their tutorials?

查看:142
本文介绍了为什么Angular在其教程中需要服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看快速启动

Looking at the quick start and step by step tutorials, Angular requires a server.

为什么Angular需要服务器?

我想一直专注于UI并始终拥有一台工作的服务器,这使我很慢-尤其是在一个大型项目中,该服务器一直不稳定,并且有大量集成未在本地配置.

I'd like to focus on UI and having a working server all the time slows me down - especially in a big project, where the server is not stable all the time and has tons of integrations which aren't configured locally.

编辑[2015/08/12]:似乎服务器是必需的.尝试运行逐步指南,加载时不起作用静态html(没有服务器).什么也没显示. myapp标签只是不受控制器限制.

Edit [2015/08/12]: It seems that the server is required. Trying to run the step by step guide, doesn't work when loading the html statically (without a server). Nothing is shown. The myapp tag just doesn't get bounded the controller.

推荐答案

出于安全目的,浏览器不允许在文件系统上直接请求.它在处理angular中的路由和ajax请求时给您错误.因此,您必须使用简单的HTTP服务器,也可以使用nodejs创建它.

For security purpose, browser does not allow direct request on file system. It gives you error while working with routing and ajax requests in angular. So, you have to use simple HTTP server or you can create it using nodejs.

引用将node.js用作简单的Web服务器

在Linux中安装apache2服务器:

sudo apt-get install apache2

之后,您只需要将代码放入/var/www/yourDirectory中即可.现在,您可以通过http://localhost/yourDirectory

After that you just have to put your code in /var/www/yourDirectory. Now you can access your code via http://localhost/yourDirectory

这篇关于为什么Angular在其教程中需要服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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