0

I'm developing an app using angular 9 and I need to add a popup message that asks to enable cookies at the bottom in my home page(as I have seen in most websites). Is there a way to do this. Please help (I'm a beginner in angular)

1 Answers1

0

Add below links in index.html:

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.css" />
  <script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.1.0/cookieconsent.min.js"></script>

Add below logic in app.component.ts on ngOnInit:

let cc = window as any;
       cc.cookieconsent.initialise({
         palette: {
           popup: {
             background: "#164969"
           },
           button: {
             background: "#ffe000",
             text: "#164969"
           }
         },
         theme: "classic",
         content: {
           message: this.cookieMessage,
           dismiss: this.cookieDismiss,
           link: this.cookieLinkText,
           href: environment.Frontend + "/dataprivacy" 
         }
       });

Ref: https://developersde.azurewebsites.net/2018/10/29/implementing-cookie-for-angular-app/

Sravan Kumar
  • 27
  • 1
  • 1
  • 5