I have recently decided to start trying to make a site compliant with EU cookie laws. I am using AngularJS as my front end framework. I have been looking at these jquery plugins:
https://silktide.com/tools/cookie-consent/
http://cookiesdirective.com/
However I would prefer to use an angular first solution if that is at all possible. Does anyone know of any angular directive that would be able to handle this?
Easy as that.
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;
}
};
}
};
});
Add style and animation to taste.
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