I'm building front-end with Angular and back-end with Ruby on Rails. I have a tag below and I would like to trigger a function and redirect users to other page when it is pressed.
<a class="page-header--transparent-nav-item" ng-click="deleteSession()"
href="#home">Logout</a>
It seems "deleteSession()" is working. But it does not redirect to "#home". How do I make sure to redirect users?
答案 0 :(得分:0)
请尝试如下所示。使用$window
服务。
.controller('ExampleController', ['$scope', '$window', function($scope, $window) {
$scope.deleteSession= function () {
$window.location.href = yoururlhere;
};
}