Comments (4)
It happens very rarely that's why it is difficult to find the origin of the problem.
Whenever the user change the website language, I call "updateCookiePopupLanguage()" to modify the popup if it is visible.
private updateCookiePopupLanguage() {
this.translateService
.get(['cookie.header', 'cookie.message', 'cookie.dismiss', 'cookie.allow', 'cookie.deny', 'cookie.link', 'cookie.policy'])
.subscribe(data => {
this.ccService.getConfig().content = this.ccService.getConfig().content || {};
// Override default messages with the translated ones
this.ccService.getConfig().content.header = data['cookie.header'];
this.ccService.getConfig().content.message = data['cookie.message'];
this.ccService.getConfig().content.dismiss = data['cookie.dismiss'];
this.ccService.getConfig().content.allow = data['cookie.allow'];
this.ccService.getConfig().content.deny = data['cookie.deny'];
this.ccService.getConfig().content.link = data['cookie.link'];
this.ccService.getConfig().content.policy = data['cookie.policy'];
try {
this.ccService.destroy(); // remove previous cookie bar (with default messages)
} catch (e) {
this.consoleLoggerService.error('updateCookiePopupLanguage, this.ccService.destroy() crashed', e);
}
const cookieStatus = localStorage.getItem(Constants.cookieStatus);
this.consoleLoggerService.log('cookieStatus', cookieStatus);
if (cookieStatus && (cookieStatus === 'allow' || cookieStatus === 'dismiss')) {
this.consoleLoggerService.log('do not show again the cookie popup');
return;
}
this.ccService.init(this.ccService.getConfig()); // show popup
});
}
from ngx-cookieconsent.
Hi @Kenji94 ,
I've just tested with your config on latest version of Angular (v9.1.0) and never encountered this error... I'm afraid there is not much i can do at this point...
Why do you need to call this.ccService.destroy()
? and where do you call it?
from ngx-cookieconsent.
I also regularly encounter this error in my Angular 9 application. It happens occasionally when ccService.destroy()
is called.
I need to call this method when I load the consent from a different source, and need to hide the CC bar.
I suspect it happens because the destroy() call tries to access the options object, which might not yet have been initialized in the view. A null check would probably fix it.
from ngx-cookieconsent.
Some further investigation tells me that the https://github.com/osano/cookieconsent dependency might be the problem.
from ngx-cookieconsent.
Related Issues (20)
- ngx-Cookie Consent
- [Bug] HOT 2
- [Bug] Angular 13 not supported HOT 1
- [Bug] SSR - Cookie popup has not yet been instantiated. Cannot invoke {{methodName}}
- [Bug] ccService.initializing, ccService.initialized and ccService.initializationError does not exist on NgcCookieConsentService HOT 2
- [Feature] Angular 14 HOT 22
- The automated release is failing 🚨
- [Bug] Wrong `peerDependencies` for rxjs for Angular v14+ HOT 3
- Does not save its own cookie on AWS amplify HOT 1
- Cookie popup not appearing in published website HOT 1
- [Bug] Restrictive `peerDependency` of `rxjs` causes conflicts with other packages
- [Bug] whitelistPage and blacklistPage options are not working well
- [Bug] Support for Angular 15 HOT 1
- The automated release is failing 🚨
- [Bug] Needs to be Ivy compliant [Angular 16] HOT 18
- How do I opt-in a session when cookie consent is not required?
- Cookie-banner disabled by AdBlocker[Bug] HOT 1
- [chore] Update to latest Nx version
- [chore] Setup Nx Dependency Check ESLint
- [Feature] Add mobileForceFloat option HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ngx-cookieconsent.