角度 html5 模式不重定向
Angular html5 mode not redirecting
我正在使用AngularJs和Ruby on Rails。
我将 html5 选项设置为 true 在角度:$locationProvider.html5Mode(true)
但是现在,当我尝试浏览应用程序中的页面时,它只会更改浏览器 URL 栏中的 URL。但是除非我重新加载页面,否则它本身的页面不会更改。只有这样,它才会转到指定的页面。
这就是我的角度路由的样子:
@test.config(['$routeProvider', '$locationProvider', ($routeProvider, $locationProvider) ->
# Route for '/'
$routeProvider.when('/', { templateUrl: '../../views/visitors/index.html.erb', controller: 'VisitorsCtrl' } )
$routeProvider.when('/users', { templateUrl: '../../views/users/index.html.erb', controller: 'UsersCtrl' } )
# Default
$routeProvider.otherwise( { redirectTo: "/" } )
$locationProvider.html5Mode(true)
])
在根页面上,我有一个元素:<h2><a ng-click="viewUsers()">Users</a></h2>
这里称viewUsers()
:
@test.controller 'VisitorsCtrl', ['$scope', '$location', '$http', ($scope, $location, $http) ->
$scope.viewUsers = ->
$location.path('/users')
console.log("Redirected")
]
要使这种路由工作,还需要什么?
新的角度路线:
Test.config ($routeProvider, $locationProvider) ->
$routeProvider
.when '/',
templateUrl: '../../views/visitors/index.html.erb',
controller: 'VisitorsCtrl'
.when '/users',
templateUrl: '../../views/users/index.html.erb',
controller: 'UsersCtrl'
请尝试使用以下方法:
$window.location.href = '/users'
相关文章:
- 通过javascript重定向html传递php变量
- JavaScript下拉菜单-点击按钮并根据所选值重定向到url
- 使用angular重定向到html页面
- 如何在chrome扩展中重定向到html页面
- 无法从jquery Mobile导航栏重定向到另一个页面
- ng视图外的链接重定向到ng视图内的页面
- 在phonegap应用程序内部重定向不起作用
- 查看完某个页面后,在重定向的页面上弹出js模式
- 重定向到具有轨道的html5模式中的正确角度路线
- Pinterest API应用程序处于开发模式(因此我可以使用http重定向)
- 在 PHP 中创建模式警报而不是页面重定向验证
- 重定向(URl)提供控制器视图 URI模式
- 页面加载上的加载模式&5秒后重定向
- 重定向时关闭模式窗口.不,不会在关闭时重定向
- 角度 html5 模式不重定向
- 杜兰达尔登录页面重定向模式
- 在不重定向的情况下以模式发送表单数据
- 使用javascript或jquery修改href-或-URL重定向/重写和模式匹配
- 表单提交后重定向回页面并显示模式
- 如何在表单提交而不是页面重定向时生成模式