Angularjs $routeProvider未重定向
我有这样的config()Angularjs $routeProvider未重定向,angularjs,Angularjs,我有这样的config() function config($httpProvider, $routeProvider) { $httpProvider.interceptors.push('httpInterceptorService'); $routeProvider .when('/detail/:id', { controller: 'CourseDetailController', controllerAs: 'vm', templateUrl: 'te
function config($httpProvider, $routeProvider) {
$httpProvider.interceptors.push('httpInterceptorService');
$routeProvider
.when('/detail/:id', {
controller: 'CourseDetailController',
controllerAs: 'vm',
templateUrl: 'templates/course-detail.html'
})
.otherwise({
redirectTo: '/'
});
}
看法
我试过了
href=“/#/detail/{{course.\u id}}}”
中删除了/#
,但这次URL
变为http://localhost:5000/detail/57029ed4795118be119cc43d
,而不是拿起angular router并发出服务器请求URL
http://localhost:5000/#!/详图/F57029ed4795118be119cc43d
没有编码字符,此时间视图已正确更改有什么想法吗?在配置中执行此操作
function config($httpProvider, $routeProvider, $locationProvider) {
$locationProvider.hashPrefix('');
然后尝试使用ng href
<a class="course--module course--link" ng-href="/#/detail/{{ course._id }}">
您需要在对象窗口中使用浏览器级API,或者可以在控制器中插入$window引用
window.location.href=”http://www.google.com";代码>
$window.location.href=”http://www.google.com";代码>
function config($httpProvider, $routeProvider, $locationProvider) {
$locationProvider.hashPrefix('');
<a class="course--module course--link" ng-href="/#/detail/{{ course._id }}">
<a class="course--module course--link" ng-href="/#!/detail/{{ course._id }}">