原文来自 http://blog.csdn.net/github_38469481/article/details/70598066
使用ng-route大于1.6.0的版本时,地址中的 "/" 会自动被解析 而且还会在URL地址中加入#! 导致路由不能正常的工作
如图所示
解决此问题的方法有两种 :
1、如果坚持使用当前版本的angular则在配置路由时添加如下代码
-
$locationProvider.hashPrefix('');
代码如下所示
-
var myApp= angular.module('myApp',['ngRoute']);
-
-
myApp.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider){
-
-
//这是因为Angular 1.6 版本更新后 对路由做的处理,这样才可以和以前版本一样正常使用
-
$locationProvider.hashPrefix('');
-
-
$routeProvider
-
.when('/RuKu',{
-
controller:'Acontroller',
-
templateUrl:"./viewes/viw1.html",
-
})
-
.when('/OrderDetial',{
-
controller:'Bcontroller',
-
templateUrl:"./viewes/viw2.html"
-
})
-
.otherwise('/RuKu');
-
}]);
效果如下所示 路由可以正常工作
2、使用比1.6.0的低的版本。