为什么AngularJS NG-视图不在本地工作? [英] Why does AngularJS ng-view not work locally?

查看:116
本文介绍了为什么AngularJS NG-视图不在本地工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经工作了几个小时让我的链接,通过点击与我AngularJS应用不同的看法。

I have been working for a few hours on getting my links to click through to different views with my AngularJS app.

不过,我只能似乎得到功能上Plunker联机工作。

However, I can only seem to get the functionality to work online on Plunker.

我一直试图在本地测试我的机器上的点击功能和NG-观点似乎并不加载。当我下载我的Plunker code,我知道是正确的,因为它正在Plunker,NG-观点似乎一旦它的本地托管辞掉工作。

I've been trying to test the click-through functionality on my machine locally and ng-view does not seem to load. When I download my Plunker code that I know is correct because it is working on Plunker, ng-view seems to quit working once it's hosted locally.

我也有类似的问题与NG-包括和指示,我定义为自己的HTML标签。

I've also had similar issues with ng-include and directives I've defined as their own HTML tags.

有一个原因,这些并不在我的电脑上的本地工作? (和办法,我可以修复它​​用于测试目的?)

Is there a reason these don't work locally on my computer? (And a way I can fix it for testing purposes?)

您可以查看一些code我谈论关于Plunker 这里的如果你愿意的话。

You can view some of the code I'm talking about on Plunker here, if you'd like.

推荐答案

NG-观点和NG-包括使Ajax请求服务模板文件。因为你在本地运行它,它不能使该请求。解决这个一个简单的解决方法是使用 HTTP服务器超过本地服务器为你的内容。

ng-view and ng-include make ajax requests to serve the template file. Because you're running it locally, it can't make that request. An easy fix around this is to use http-server to serve your contents over a local server.

这篇关于为什么AngularJS NG-视图不在本地工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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