我正在使用auth-http-interceptor来广播登录确认。我有一个main.html,它应该检查用户是否已登录。
<div class="auth-tripdelta" ng-class="{'wrapper':locationFunction(),'wrapper2': !locationFunction() }">
<bus-search class="block">
</bus-search>
<div class="container">
<div class="row">
</div>
</div>
<div ui-view></div>
<newsletter class="visible-sm visible-md visible-lg" ng-show="locationFunction()"></newsletter>
</div>
和指令
.directive('authTripdelta',function() {
return {
restrict: 'C',
link: function(scope ,elem, attrs ) {
scope.$on('event:auth-loginRequired', function() {
console.log('test1'); // todo modal call above
});
scope.$on('event:auth-loginConfirmed', function() {
console.log('test2');
});
}
}
});
<form class="form" name="form" ng-submit="login()" novalidate>
<div>
<a class="btn btn-facebook loginButton" href="/authenticate/facebook" >
<i class="fa fa-facebook"></i> Connect with Facebook
</a>
<a class="btn btn-google-plus loginButton" href="/authenticate/google">
<i class="fa fa-google-plus"></i> Connect with Google+
</a>
</div>
</form>
和登录控制器
$scope.login = function() {
$http.post('/login').success(function() {
authService.loginConfirmed();
});
};
1)但是,我没有获得任何console.logs。我的代码有什么问题吗?
2)我是对的,登录确认只在我的登录会话中被解雇一次而不是几次?