-1

我在 Angular 中使用ngx-cookie-consent。我想找到一种以编程方式显示/隐藏弹出窗口的方法

我尝试close通过实例访问该方法,NgcCookieConsentService但没有成功

这个想法是有一个这样的链接:

html:

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

.ts

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

2 回答 2

1

在您的构造函数中,您可以声明 NgcCookieConsentService 类的实例:

private ccService: NgcCookieConsentService

然后在您的函数中,您可以调用 open 函数来重新打开 cookie 弹出窗口。

this.ccService.open();
于 2020-01-29T14:04:56.067 回答
0

我发现的方法是从 NgcCookieConsentService 实例调用我的函数fadeIn()fadeOut()感谢@Xperiencing让我回顾这个问题

所以在.ts

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

然后在html中

<div (click)="opencc()">
    ...
</div
于 2020-01-29T15:00:14.750 回答