Json AngularJS页面一直在重新加载
我使用Node制作了一个API。我使用Postman测试了我的API,效果很好。所以我从Angular开始显示页面 所以当我访问页面Json AngularJS页面一直在重新加载,json,angularjs,node.js,Json,Angularjs,Node.js,我使用Node制作了一个API。我使用Postman测试了我的API,效果很好。所以我从Angular开始显示页面 所以当我访问页面http://localhost:3000/tests页面一直在重新加载!我不明白为什么,因为我只是从服务器请求一些JSON,并在页面上显示 代码如下: 模块/core.js: (function() { angular.module('app', ['ngRoute', 'test']); })(); controllers/test.js: (func
http://localhost:3000/tests
页面一直在重新加载!我不明白为什么,因为我只是从服务器请求一些JSON,并在页面上显示
代码如下:
模块/core.js:
(function() {
angular.module('app', ['ngRoute', 'test']);
})();
controllers/test.js:
(function() {
angular.module('test', [])
.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) {
$routeProvider
.when('/tests', {
templateUrl: '/views/tests.html',
controller: 'TestController',
})
$locationProvider.html5Mode(true);
}])
.controller('TestController', ['$http', '$scope', '$routeParams', function ($http, $scope, $routeParams) {
$http.get('/api/tests')
.success(function (data) {
console.log(data);
$scope.tests = data;
});
}]);
})();
views/tests.html:
<div class="row">
<div class="col-sm-3">
<div class="test" ng-repeat="test in tests">
<h4>{{ test.title }}</h4>
<p><small>{{ test.url }}</small></p>
</div>
</div>
</div>
{{test.title}}
{{test.url}}
views/index.html:
<!doctype html>
<html ng-app="app">
<head>
<title>MEAN App</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular-route.min.js"></script>
<script src="/controllers/test.js"></script>
<script src="/modules/core.js"></script>
<style>
body { padding-top:80px; }
</style>
</head>
<body>
<div class="container" ng-view>
</div>
</body>
</html>
平均应用程序
正文{padding top:80px;}
哪些浏览器出现这种行为?我正在使用FireFox,但我也测试了Chrome,它们也有同样的行为!这里也有同样的问题,但还没有解决。尽管尝试从“npm start”命令窗口调查日志。在我的例子中,它请求my home.html和favicon.ico,并且多次收到404。我不知道为什么会继续重新加载页面。可能是某个地方的模板URL无效