处理cookie法律合规的任何Angular指令?

Bob*_*ent 6 cookies jquery angularjs angularjs-directive

我最近决定开始尝试使网站符合欧盟cookie法律.我使用AngularJS作为我的前端框架.我一直在看这些jquery插件:

https://silktide.com/tools/cookie-consent/

http://cookiesdirective.com/

但是,如果可能的话,我宁愿使用角度优先解决方案.有谁知道任何能够处理这个问题的角度指令?

Est*_*ask 19

很简单.

angular.module('consent', ['ngCookies'])
.directive('consent', function ($cookies) {
  return {
    scope: {},
    template:
      '<div style="position: relative; z-index: 1000">' +
      '<div style="background: #ccc; position: fixed; bottom: 0; left: 0; right: 0" ng-hide="consent()">' +
      ' <a href="" ng-click="consent(true)">I\'m cookie consent</a>' +
      '</div>' +
      '</div>',
    controller: function ($scope) {
      var _consent = $cookies.get('consent');
      $scope.consent = function (consent) {
        if (consent === undefined) {
          return _consent;
        } else if (consent) {
          $cookies.put('consent', true);
          _consent = true;        
        }
      };
    }
  };
});
Run Code Online (Sandbox Code Playgroud)

添加风格和动画品味.