我正在开发 Angular 应用程序,当我使用以下网址点击浏览器时: http://localhost/angular/MyAngularRewind/
,index.html 没有打开,但实际上它应该已经打开索引.html。
C:\wamp\www\Angular\MyAngularRewind
---> 这是我拥有index.html的路径,请参见下面的屏幕截图
但是当我点击以下网址时页面正在打开:http://localhost/angular/MyAngularRewind/index.html
并且它更改为http://localhost/angular/MyAngularRewind/index.html#/
理想情况下应该发生以下事情:当我点击网址时:http://localhost/angular/MyAngularRewind/
它应该打开页面,网址自动更改为http:///localhost/angular/MyAngularRewind/index.html/#/
,但它没有发生,我不知道为什么会发生这种情况。
索引.html
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My HTML File</title>
<title>Google Phone Gallery</title>
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="css/bootstrap.css">
<script src="lib/angular/angular.js"></script>
<script src="js/controllers.js"></script>
<script src="js/routes.js"></script>
</head>
<body ng-controller="appCtrl">
<div class="" ng-view></div>
</body>
</html>
Javascript:
angular.module('myApp', []).
config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/',
{
templateUrl: 'partials/partial-For-routes-1.html',
controller: appCtrl
}).
when('/page-2',
{
templateUrl: 'partials/partial-For-routes-2.html',
controller: appCtrl
}).
when('/page-3',
{
templateUrl: 'partials/partial-For-routes-3.html',
controller: appCtrl
}).
otherwise({redirectTo:("/")})
}]);
预先感谢您的帮助。
最佳答案
问题可能出在你的服务器上,而不是 Angularjs - 你需要指示服务器在访问目录(/angular/MyAngularRewind/)时自动提供 index.html。
话虽如此,我不确定您使用的是哪个服务器,所以我无法提供解决方案
关于AngularJs:深层链接默认 Index.Html 未打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16302948/