我正在尝试让允许Cookie按钮与ngx- Cookies连接,但无论何时我点击允许,hasConsented()仍然返回假,甚至在点击允许之后,当我刷新页面时弹出窗口总是显示。到目前为止,我已经尝试了info,选择加入或选择退出我的设置,但没有成功。
按钮字符串文本在i18n文件中。
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
// you can use this.ccService.getConfig() to do stuff...
if (event.status === 'deny') {
this.openCookies()
}
if (event.status === 'allow') {
this.popupCloseSubscription = this.ccService.popupClose$.subscribe(() => {
this.ccService.toggleRevokeButton(false)
})
}
})const cookieConfig: NgcCookieConsentConfig = {
cookie: {
domain: environment.domain,
},
position: 'bottom-left',
theme: 'classic',
palette: {
popup: {
background: '#000000',
text: '#ffffff',
link: '#ffffff',
},
button: {
background: '#f9ae05',
text: '#000000',
border: '#f9ae05',
},
},
type: 'opt-out',
content: {
href: environment.privacyUrl,
},
}当我刷新页面时,消息会再次打开。有什么帮助吗?
发布于 2019-11-29 16:15:00
这可能有点晚了,但我已经找到了来自ngx-cookieconsent创建者的答案:
https://github.com/tinesoft/ngx-cookieconsent/issues/4
更新'domain‘属性对我在项目中使用的一个angular应用程序有帮助。
https://stackoverflow.com/questions/57724955
复制相似问题