Ng-include 未填充 div
Ng-include not populating div
在我的网页上,我有多个实例会显示相同的 table。因此,我没有在每次使用 AngularJS 中的 ng-include 时都对 table 进行硬编码。但是由于某种原因,一旦我将 table 放在它自己的 html 页面中并在其位置放置一个 ng-include,它就根本不会出现在页面上。我得到的唯一线索是在控制台日志中它有一个错误说明 "angular.js:9827 GET http://localhost:58893/Dashboards/project-information.html 404 (Not Found)"
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>
有些服务器不允许访问视图文件夹。
在您现有的 Scripts 文件夹上创建一个文件夹 "includes",然后将 html 放入。
在 ng-include 上,使用新路径:
<div
class="active content table-responsive"
ng-include="'/Scripts/includes/project-information.html'">
</div>
在我的网页上,我有多个实例会显示相同的 table。因此,我没有在每次使用 AngularJS 中的 ng-include 时都对 table 进行硬编码。但是由于某种原因,一旦我将 table 放在它自己的 html 页面中并在其位置放置一个 ng-include,它就根本不会出现在页面上。我得到的唯一线索是在控制台日志中它有一个错误说明 "angular.js:9827 GET http://localhost:58893/Dashboards/project-information.html 404 (Not Found)"
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>
有些服务器不允许访问视图文件夹。
在您现有的 Scripts 文件夹上创建一个文件夹 "includes",然后将 html 放入。
在 ng-include 上,使用新路径:
<div
class="active content table-responsive"
ng-include="'/Scripts/includes/project-information.html'">
</div>