在我的网页上,我有多个实例,其中会显示相同的表格。因此,每次我使用AngularJS中的ng-include时,都不要对表进行硬编码。但出于某种原因,一旦我将表放在自己的html页面中并在其位置放置了ng-include,它就不会出现在页面上。我得到的唯一线索是在控制台日志中它有一个错误,指出“angular.js:9827获取http://localhost:58893/Dashboards/project-information.html 404(未找到)”
index.cshtml
<div class="ibox-content" id="ibox-2"><!--DIV CONTENT-->
<div class="active content table-responsive" ng-include="'project-information.html'"></div>
</div>
项目information.html
<table class="table selectOption">
<thead>
<tr>
<th>#</th>
<th>Project </th>
<th>Name </th>
<th>Phone </th>
<th>Company </th>
<th>Date</th>
</tr>
</thead>
<tbody>
<!--Angular; Repeats all of the content in the dTIMS project array-->
<tr class="option" ng-repeat="product in projectCtrl.products">
<td>{{ product.id }}</td>
<td>{{ product.name }}</td>
<td>{{ product.supervisor }}</td>
<td>{{ product.phone }}</td>
<td>{{ product.company }}</td>
<td>{{ product.date }}</td>
</tr>
</tbody>
app.js
app.controller('ProjectController', function () {
this.products = projects
});
header.cshtml
<html ng-app="dTIMSApp">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript" src="~/Scripts/app.js"></script>
</head>
<body ng-controller="ProjectController as projectCtrl">
....call to the index page inside here
</body>
</html>
答案 0 :(得分:1)
某些服务器不允许访问views文件夹。
在现有的Scripts文件夹中创建一个“includes”文件夹,并将html放入。
在ng-include上,使用新路径:
<div
class="active content table-responsive"
ng-include="'/Scripts/includes/project-information.html'">
</div>