I want get cookie value and set to a provider. This post https://stackoverflow.com/a/20415679/772481 mentioned $cookiesProvider. But how do I use it?
mod.config(["someProvider", "$cookiesProvider", function(someProvider, $cookiesProvider) {
someProvider.set('configs', {'token': $cookiesProvider["XSRF-TOKEN"]})
}]);
You can inject $cookies
manually:
myApp.config(function() {
var $cookies;
angular.injector(['ngCookies']).invoke(['$cookies', function(_$cookies_) {
$cookies = _$cookies_;
}]);
// here you can use $cookies as usual
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With