做角意见工作当一个站点从本地文件系统服务? [英] Do angular views work when a site is served from the local file system?

查看:105
本文介绍了做角意见工作当一个站点从本地文件系统服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的角度来开发应用程序。我开发了我的本地文件系统,在Windows上。然而,当我让角route.js ,每当我打 index.html的与我的浏览器,它,而不是去到的index.html#/ C:/

I'm using angular to develop an application. I'm developing off my local file system, on Windows. However, when I enable angular-route.js, whenever I hit index.html with my browser, it instead goes to index.html#/C:/.

我的路线定义是:

myApp.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/', {templateUrl: 'home.html', controller: 'HomeCtrl'});
}

我认为这将导致该网站打破,因为 / C:/ 不匹配任何角度路线。什么错?我该如何解决这个问题?

I think this causes the site to break, because /C:/ doesn't match any angular routes. What's going wrong? How do I fix this?

推荐答案

有关路由和放大器;阿贾克斯(及更多)才能正常工作,运行本地开发服务器;避免使用文件:// 进行开发,因为浏览器有不同的规则,它

For routing & ajax (& more) to work properly, run a local development server; avoid use of file:// for development, since browsers have different rules for it.

之类的工具自耕农 + 发电机角将自动设置了一个gruntfile一个服务器任务,它将运行 服务器节点连接到本地服务的文件。

Tools like yeoman + generator-angular will automatically set up a gruntfile with a server task, which will run a node-connect server to locally serve your files.

您可以做到这一点。


  • 蟒蛇:(3)蟒蛇-m http.server 8001 (与SimpleHttpServer 2替换http.server)

  • 的node.js +连接

  • 红宝石+机架

  • 从angularjs教程( 5号与code工作下) - 你需要在你的系统上运行的http服务器,但是如果你不已经已经安装了一个,你可以使用节点运行脚本\\ WEB-server.js,一个简单的捆绑HTTP服务器。

  • python: (3)python -m http.server 8001 (replace http.server with SimpleHttpServer in 2)
  • node.js + connect
  • ruby + rack
  • From the angularjs tutorial (number 5 under "working with the code") - "You need an http server running on your system, but if you don't already have one already installed, you can use node to run scripts\web-server.js, a simple bundled http server."

这意见的回应:对于PhoneGap的,使用的PhoneGap的工具的。这不正是我所说的,它运行一个本地服务器。

Response from comments: For phonegap, use the phonegap tools. It does exactly what I said, it runs a local server.

这篇关于做角意见工作当一个站点从本地文件系统服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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