F
F
Forge01002015-11-14 23:24:20
Angular
Forge0100, 2015-11-14 23:24:20

How to use the AngularJS Cookie module outside of controllers?

Hello, I started to learn AngularJS and ran into the problem of using the cookie module ( ngCookies ) outside of controllers, namely in the HTML attribute ng-show="$cookies.get('token') != null" , to show the block only if the cookie exists token
How to fix this? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Lyzlov, 2015-11-14
@Forge0100

Put the token in $rootScope and just use ng-show="token != null"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question