按<a> tag

时间:2016-04-27 23:54:17

标签: ruby-on-rails angularjs redirect

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?

1 个答案:

答案 0 :(得分:0)

请尝试如下所示。使用$window服务。

 .controller('ExampleController', ['$scope', '$window', function($scope, $window) {

    $scope.deleteSession= function () {
            $window.location.href = yoururlhere;
        };
}