3

How can I remove the small "Cookie policy" window? I am using latest version of ngx-cookieconsent with Angular 7.2

enter image description here

Martin Andersen
  • 2,460
  • 2
  • 38
  • 66

5 Answers5

2

i forced to close it by:
this.ccService.close(false);
or to hide by this.ccService.fadeOut();

since 'revokable': false option didnt work.

ya_dimon
  • 3,483
  • 3
  • 31
  • 42
1

I'm a bit late for this answer but had the same issue today and I found some workaround.

this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
  (event: NgcStatusChangeEvent) => {
    if (event.status === 'allow') {
      this.ccService.close(false); // Hide revoke button after accepting cookies
    }        
  });

Below this or at the end of ngOnInit() I added this:

if (this.ccService.hasConsented()) {
  this.ccService.destroy();      
}

Code above check if you get consent and if yes it will destroy popup instance.

Andurit
  • 5,612
  • 14
  • 69
  • 121
  • Be careful when using `this.ccService.destroy();` because you will destroy the cookieconsent instance and will not be able to interact with it anymore. example : `this.ccService.hasConsented();` will produce an error. – Fred Aug 26 '21 at 10:50
  • but it doesn't permanently disables the pop-up, once I refresh the pop-up reappears... It should be more of cookie dependent thing, so any ways to acheive that? – Shivam Paliya Apr 23 '22 at 10:01
1

An alternative solution is to add the following in the app.component.scss:

/* Hide ng cookies consent revoke button */
::ng-deep  .cc-revoke {
      display: none;
  }
aga
  • 41
  • 6
0

Have you try the this.ccService.getConfig().autoOpen=false ? After saving cookie, i set it to false.

Lio MC
  • 31
  • 7
  • This does not provide an answer to the question. You can [search for similar questions](https://stackoverflow.com/search), or refer to the related and linked questions on the right-hand side of the page to find an answer. If you have a related but different question, [ask a new question](https://stackoverflow.com/questions/ask), and include a link to this one to help provide context. See: [Ask questions, get answers, no distractions](https://stackoverflow.com/tour). – Dwhitz Apr 18 '19 at 13:54
0

This worked for me:

ngOnInit() {
    this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
      (event: NgcStatusChangeEvent) => {
        this.ccService.fadeOut();
      });
    if (this.ccService.hasAnswered()) this.ccService.toggleRevokeButton(false);
}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83