2015-08-11 1 views
0

На моей веб-странице У меня есть несколько экземпляров, где будет показана одна и та же таблица. Поэтому вместо того, чтобы таблица была жестко закодирована каждый раз, когда я использую ng-include из AngularJS. Но по какой-то причине, когда я помещаю таблицу внутри своей собственной html-страницы и помещаю ng-include на ее место, она просто не появляется на странице вообще. Единственный ключ я получаю в консоли журнал имеет ошибку о том, "angular.js: 9827 ПОЛУЧИТЬ http://localhost:58893/Dashboards/project-information.html 404 (Не найдено)"Ng-include не заполняется div

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> 

enter image description here

+0

кажется вопрос путь к файлу, вы можете поделиться шаблон пути к файлу? – user2954587

+1

Ошибка просто говорит, что файл 'http: // localhost: 58893/Dashboards/project-information.html' не найден. Вы уверены, что путь правильный? – Joy

+0

@ user2954587 Я запутался, не подключен ли ng-include к странице, на которую он ссылается? – Markus

ответ

1

Некоторые серверы не позволяют получить доступ к папке Views.

Создайте папку «включает» в существующую папку Scripts и поместите html в.

На нг-включают в себя, используйте новый путь:

<div 
    class="active content table-responsive" 
    ng-include="'/Scripts/includes/project-information.html'"> 
</div> 

 Смежные вопросы

  • Нет связанных вопросов^_^