【发布时间】:2017-07-08 06:18:45
【问题描述】:
我刚开始使用 AngularJS。当我尝试实现以下示例时,我得到了
404 未找到
这是我的 main.html
<!DOCTYPE html>
<html ng-app="demoApp">
<script src="angular.min.js"></script>
<head>
<title>main page</title>
</head>
<body>
<div ng-view></div>
<script>
var demo = angular.module('demoApp',[]);
demo.config(function ($routeProvider){
$routeProvider
.when ('foo',{
controller : 'SimpleController',
templateUrl: 'first.html'
})
});
demo.controller('SimpleController',function($scope){
$scope.customers = [
{name: 'sac',city:'abcd'},
{name: 'mac',city:'efgh'},
{name: 'nalaka',city:'ijkl'}
];
});
</script>
</body>
</html>
我的第一个.html
<ul>
<li ng-repeat="cus in customers ">{{ cus.name }}</li>
</ul>
当我访问localhost/foo 时,我收到 404 异常。我刚开始使用 AngularJS。所以任何解决这个问题的帮助/指南都会对我有很大的帮助。
提前致谢
【问题讨论】:
-
404 用于哪个资源?服务器是在 80 端口还是其他端口运行?
-
在此服务器上找不到请求的 URL /foo。端口 80
标签: javascript angularjs routing http-status-code-404 angularjs-routing