【问题标题】:How ng-include builds url in Angular 1.5?ng-include 如何在 Angular 1.5 中构建 url?
【发布时间】:2016-08-28 13:32:32
【问题描述】:

我正在使用 Angular1.5 和 asp.net mvc。

默认情况下,当我的应用程序加载时它指向http://domainname/components/Webui/Home/Instructions

首页 - 控制器, 说明 - 操作

 public class HomeController : Controller
    {       

        public ActionResult Instructions()
        {
            return View();
        }
    }

上面的url返回一个html

其中包含以下内容

<div>
<div ng-include src="app/Layout/shell/Shell.html" class="height100">

</div>
</div>

但它无法下载 shell.html。 它正在生成错误的网址,如下所示

http://domainname/components/Webui/Home/app/layout/shell/Shell.html

在上面的 url 为什么 Home 来了?

我的文件夹结构是

app
  layout
     shell
        Shell.html
Controllers
Views
  Home
     Index.cshtml
     Instructions.cshtm

如有错误请指正。

【问题讨论】:

    标签: angularjs asp.net-mvc angularjs-ng-include


    【解决方案1】:

    您正在使用来自索引的相对路径。将正斜杠附加到路径以从项目根目录遍历:

    ng-include src="/app/Layout/shell/Shell.html
    

    【讨论】:

    • 在尝试该网址后是这样的http://domainname/components/app/layout/shell/Shell.html
    猜你喜欢
    • 2020-03-01
    • 2013-09-29
    • 2017-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-29
    • 2016-08-24
    • 2018-05-26
    相关资源
    最近更新 更多