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)
Asked
Active
Viewed 2,476 times
0
-
one option would be 'material snackbar' - part of angular material library – Chandra Kanth May 26 '20 at 09:38
-
1I think this could help you https://stackoverflow.com/questions/41684114/angular-2-easy-way-to-make-a-confirmation-dialog – Jakov Gl. May 26 '20 at 10:16
1 Answers
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