Do angular views work when a site is served from the local file system?

前端 未结 2 771
忘了有多久
忘了有多久 2020-12-07 02:49

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

2条回答
  •  盖世英雄少女心
    2020-12-07 03:13

    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.

    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.

    You can do this with

    • 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."

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

提交回复
热议问题