AngularJS logout not working with anonymous functions
up vote
0
down vote
favorite
I am working on AngularJS 1.5 project where I have to clear some settings before logout()
Working code (which does not clear settings)
this.logout = userSession.logout
- userSession is a service which has logout
Modified code (which clears the settings but does not logout)
this.logout = () => {
mySettings.clear()
userSession.logout
}
Html Code:
<a href="" ng-click="$ctrl.logout()">
<span class="icon-logout"</span>
</a>
angularjs
add a comment |
up vote
0
down vote
favorite
I am working on AngularJS 1.5 project where I have to clear some settings before logout()
Working code (which does not clear settings)
this.logout = userSession.logout
- userSession is a service which has logout
Modified code (which clears the settings but does not logout)
this.logout = () => {
mySettings.clear()
userSession.logout
}
Html Code:
<a href="" ng-click="$ctrl.logout()">
<span class="icon-logout"</span>
</a>
angularjs
1
(stop editing it) in your function you need to actually call the method, so changeuserSession.logout
touserSession.logout()
, whereas before you were only referencing it
– Aleksey Solovey
Nov 7 at 15:50
@AlekseySolovey It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
once again, you were referencing it. With that codethis.logout
became a method, which you can call usingthis.logout()
, or in HTML:$ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on AngularJS 1.5 project where I have to clear some settings before logout()
Working code (which does not clear settings)
this.logout = userSession.logout
- userSession is a service which has logout
Modified code (which clears the settings but does not logout)
this.logout = () => {
mySettings.clear()
userSession.logout
}
Html Code:
<a href="" ng-click="$ctrl.logout()">
<span class="icon-logout"</span>
</a>
angularjs
I am working on AngularJS 1.5 project where I have to clear some settings before logout()
Working code (which does not clear settings)
this.logout = userSession.logout
- userSession is a service which has logout
Modified code (which clears the settings but does not logout)
this.logout = () => {
mySettings.clear()
userSession.logout
}
Html Code:
<a href="" ng-click="$ctrl.logout()">
<span class="icon-logout"</span>
</a>
angularjs
angularjs
asked Nov 7 at 15:46
Dot Net Dev
946
946
1
(stop editing it) in your function you need to actually call the method, so changeuserSession.logout
touserSession.logout()
, whereas before you were only referencing it
– Aleksey Solovey
Nov 7 at 15:50
@AlekseySolovey It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
once again, you were referencing it. With that codethis.logout
became a method, which you can call usingthis.logout()
, or in HTML:$ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03
add a comment |
1
(stop editing it) in your function you need to actually call the method, so changeuserSession.logout
touserSession.logout()
, whereas before you were only referencing it
– Aleksey Solovey
Nov 7 at 15:50
@AlekseySolovey It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
once again, you were referencing it. With that codethis.logout
became a method, which you can call usingthis.logout()
, or in HTML:$ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03
1
1
(stop editing it) in your function you need to actually call the method, so change
userSession.logout
to userSession.logout()
, whereas before you were only referencing it– Aleksey Solovey
Nov 7 at 15:50
(stop editing it) in your function you need to actually call the method, so change
userSession.logout
to userSession.logout()
, whereas before you were only referencing it– Aleksey Solovey
Nov 7 at 15:50
@AlekseySolovey It is working, Thanks, But I don't understand why it was working with
this.logout = userSession.logout
(without parentheses)– Dot Net Dev
Nov 7 at 15:59
@AlekseySolovey It is working, Thanks, But I don't understand why it was working with
this.logout = userSession.logout
(without parentheses)– Dot Net Dev
Nov 7 at 15:59
once again, you were referencing it. With that code
this.logout
became a method, which you can call using this.logout()
, or in HTML: $ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
once again, you were referencing it. With that code
this.logout
became a method, which you can call using this.logout()
, or in HTML: $ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You forgot the parentheses when calling userSession.logout.
Should be:
this.logout = () => {
mySettings.clear()
userSession.logout(); // added parentheses
}
It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You forgot the parentheses when calling userSession.logout.
Should be:
this.logout = () => {
mySettings.clear()
userSession.logout(); // added parentheses
}
It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
add a comment |
up vote
0
down vote
accepted
You forgot the parentheses when calling userSession.logout.
Should be:
this.logout = () => {
mySettings.clear()
userSession.logout(); // added parentheses
}
It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You forgot the parentheses when calling userSession.logout.
Should be:
this.logout = () => {
mySettings.clear()
userSession.logout(); // added parentheses
}
You forgot the parentheses when calling userSession.logout.
Should be:
this.logout = () => {
mySettings.clear()
userSession.logout(); // added parentheses
}
answered Nov 7 at 15:51
Victor P
7181020
7181020
It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
add a comment |
It is working, Thanks, But I don't understand why it was working withthis.logout = userSession.logout
(without parentheses)
– Dot Net Dev
Nov 7 at 15:59
It is working, Thanks, But I don't understand why it was working with
this.logout = userSession.logout
(without parentheses)– Dot Net Dev
Nov 7 at 15:59
It is working, Thanks, But I don't understand why it was working with
this.logout = userSession.logout
(without parentheses)– Dot Net Dev
Nov 7 at 15:59
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53192906%2fangularjs-logout-not-working-with-anonymous-functions%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
(stop editing it) in your function you need to actually call the method, so change
userSession.logout
touserSession.logout()
, whereas before you were only referencing it– Aleksey Solovey
Nov 7 at 15:50
@AlekseySolovey It is working, Thanks, But I don't understand why it was working with
this.logout = userSession.logout
(without parentheses)– Dot Net Dev
Nov 7 at 15:59
once again, you were referencing it. With that code
this.logout
became a method, which you can call usingthis.logout()
, or in HTML:$ctrl.logout()
– Aleksey Solovey
Nov 7 at 16:01
Ah understood, Thanks
– Dot Net Dev
Nov 7 at 16:03