angulartypescripteventscookieconsent

How can I programmatically open/close ngx cookie consent popup?


I'm using ngx-cookie-consent with Angular. I would like to find a way to programmatically display/hide the popup

I've tried accessing the method close through an instance of the NgcCookieConsentService without any success

the idea would be to have a link as so:

html:

<div>
    <span (click)="displayPopPup()"> display pop up</span>
</div>

.ts

displayPopup = () => {
    //trigger the popup display 
}

Solution

  • the way I found was to call my the function fadeIn() and fadeOut() from the NgcCookieConsentService instance. thanks to @Xperiencing for making me look back at this problem

    so in .ts

    ...
    constructor(private ccService: NgcCookieConsentService){}
    ...
    opencc(){
        this.ccService.fadeIn();
        //fadeOut to hide
    }
    

    then in htlm

    <div (click)="opencc()">
        ...
    </div