Javascript 找不到资源。描述:HTTP 404。安格拉斯
我正在创建一个angular应用程序,从asp.net webapi获取产品数据。我已经测试了asp.net webapi及其正确返回的数据。但是,在加载product.chtml页面时,找不到资源。我已经检查了html文件中的所有引用,路径似乎是正确的 请务必让我知道问题可能是什么 app.jsJavascript 找不到资源。描述:HTTP 404。安格拉斯,javascript,angularjs,Javascript,Angularjs,我正在创建一个angular应用程序,从asp.net webapi获取产品数据。我已经测试了asp.net webapi及其正确返回的数据。但是,在加载product.chtml页面时,找不到资源。我已经检查了html文件中的所有引用,路径似乎是正确的 请务必让我知道问题可能是什么 app.js (function () { "use strict"; var app = angular.module("productManagement", ["common.services
(function () {
"use strict";
var app = angular.module("productManagement", ["common.services"]);
}());
productController.js
(function () {
"use strict";
angular
.module("productManagement")
.controller("ProductController", ["productFactoryService", ProductController]);
function ProductController(productFactoryService) {
var vm = this;
vm.productData = null;
productFactoryService.GetAllRecords()
.then(function (d)
{
vm.productData = d.data;
},
function () {
alert('Error Occured !!!'); // Failed
});
}
}());
(function () {
"use strict";
angular
.module("common.services", ["$http"]);
}());
(function () {
"use strict";
angular
.module("common.services")
.factory("productFactoryService", ["$http", productFactoryService]);
function productFactoryService($http)
{
var fac = {};
fac.GetAllRecords = function () {
return $http.get('api/Product/GetAllProducts');
};
return fac;
}
}());
common.services.js
(function () {
"use strict";
angular
.module("productManagement")
.controller("ProductController", ["productFactoryService", ProductController]);
function ProductController(productFactoryService) {
var vm = this;
vm.productData = null;
productFactoryService.GetAllRecords()
.then(function (d)
{
vm.productData = d.data;
},
function () {
alert('Error Occured !!!'); // Failed
});
}
}());
(function () {
"use strict";
angular
.module("common.services", ["$http"]);
}());
(function () {
"use strict";
angular
.module("common.services")
.factory("productFactoryService", ["$http", productFactoryService]);
function productFactoryService($http)
{
var fac = {};
fac.GetAllRecords = function () {
return $http.get('api/Product/GetAllProducts');
};
return fac;
}
}());
productFactory.js
(function () {
"use strict";
angular
.module("productManagement")
.controller("ProductController", ["productFactoryService", ProductController]);
function ProductController(productFactoryService) {
var vm = this;
vm.productData = null;
productFactoryService.GetAllRecords()
.then(function (d)
{
vm.productData = d.data;
},
function () {
alert('Error Occured !!!'); // Failed
});
}
}());
(function () {
"use strict";
angular
.module("common.services", ["$http"]);
}());
(function () {
"use strict";
angular
.module("common.services")
.factory("productFactoryService", ["$http", productFactoryService]);
function productFactoryService($http)
{
var fac = {};
fac.GetAllRecords = function () {
return $http.get('api/Product/GetAllProducts');
};
return fac;
}
}());
Product.cshtml
@{
ViewBag.Title = "Product";
}
@section scripts{
<script src="bower_components/jquery/dist/jquery.min.js"></script>
<script src="bower_components/angular/angular.min.js"></script>
@*<script src="bower_components/angular-resource/angular-resource.min.js"></script>*@
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="App/app.js"></script>
<script src="config.js"></script>
<script src="~/Common/services/common.services.js"></script>
<script src="~/Common/services/productFactory.js"></script>
<script src="~/App/Product/productController.js"></script>
}
<div ng-app="productManagement" id="">
<div ng-controller="ProductController">
<h2>AngularJS CRUD operations with MVC5</h2>
<h3>List of Products</h3>
<table ng-cloak>
<thead>
<tr>
<th style="display:none">Id</th>
<th>Name</th>
<th>Category</th>
<th>Price</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="items in vm.productData">
<td hidden="hidden">Id</td>
<td>{{item.ProductName}}</td>
<td>{{item.Cost}}</td>
<td>{{item.Price}}</td>
<td>{{item.Category}}</td>
</tr>
</tbody>
</table>
</div>
</div>
@{
ViewBag.Title=“产品”;
}
@节脚本{
@**@
}
带MVC5的AngularJS积垢操作
产品清单
身份证件
名称
类别
价格
行动
身份证件
{{item.ProductName}
{{item.Cost}
{{item.Price}}
{{item.Category}
找不到哪个资源?是api/Product/GetAllProducts吗?这是我不理解的。我不认为这是api,因为我已经对api调用进行了注释,但仍然得到了错误。您可以在控制台中看到404错误的原因,它可能是所有的。这是我在控制台窗口中看到的所有内容。加载资源失败:服务器响应状态为404(未找到),似乎您甚至找不到Product.cshtml。你能让它向世界问好吗?