how to use cookiesProvider in angular config

前端 未结 3 379
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 00:53

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.con         


        
3条回答
  •  情话喂你
    2021-01-04 01:18

    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
    });
    

提交回复
热议问题