gpt4 book ai didi

javascript - angularjs ui.router 抛出错误 : Unexpected request: GET

转载 作者:行者123 更新时间:2023-12-01 16:04:59 24 4
gpt4 key购买 nike

我正在尝试使用 UI-Router 实现 AngularJS 路由。我有 index.html 文件,它试图使用 app.js 作为 javascript 加载部分 productListView.html,但我看到错误:意外请求:在我的控制台中获取 productListView.html。任何帮助将不胜感激。

index.html:

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Acme Product Management</title>
<!--Style Sheets-->
<link rel="stylesheet" type="text/css" href="styles/app.css">
<link rel="stylesheet" type="text/css" href="styles/bootstrap.css">
</head>
<body ng-app="productManagement">
<div class="container">
<div ui-view></div>
</div>
<!--Library Scripts-->
<script src="js/angular.min.js"></script>
<script src="js/angular-mocks.js"></script>
<script src="js/angular-resource.min.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<!--Application Script-->
<script src="app.js"></script>
<!--Services-->
<script src="common/services/common-services.js"></script>
<script src="common/services/productResource.js"></script>
<script src="common/services/productResourceMock.js"></script>
<!--Product Controllers-->
<script src="products/productListCtrl.js"></script>
</body>
</html>

应用程序.js:

(function(){
'use strict';
angular.module('productManagement',['common-services',
'productResourceMock',
'ui.router'])
.config(['$stateProvider',
'$urlRouterProvider',
function($stateProvider,
$urlRouterProvider){

$urlRouterProvider.otherwise('/products');

$stateProvider
.state('productList', {
url: '/products',
templateUrl: 'products/productListView.html',
controller: 'ProductListCtrl'
});
}]
);
})();

enter image description here

最佳答案

我认为,您必须更改: productResourceMock.js 文件中的 $httpBackend.whenGET(/app/).passThrough();

关于javascript - angularjs ui.router 抛出错误 : Unexpected request: GET,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29851146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com