friend 们,我是 angular js 的新手,我正在尝试使用 angular Route,但是当我点击#/home 时,它给了我一些奇怪的 URL http://127.0.0.1:3000/#!/home#%2Fhome
但默认情况下,otherwise 条件工作正常 http://127.0.0.1:3000/#!/home
app.config(['$routeProvider', function($routeProvider){
$routeProvider
.when('/home', {
templateUrl: 'views/home.html'
})
.when('/list', {
templateUrl: 'Views/listing.html',
controller: 'mycontroller'
}).otherwise({
redirectTo: '/home'
})
}]);
最佳答案
你可以试试
使用$locationProvider
angular.module('myApp', ['ngRoute'])
.config(['$locationProvider', function($locationProvider) {
$locationProvider.html5Mode(false);
$locationProvider.hashPrefix('');
}]);
关于javascript - Angular.js 路由不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51117530/