Comments (8)
Any updates?
Facing the same "problem" with my application right now. I think that would be a great enhancement
from ngx-cookieconsent.
Hey! I found this hack... This is quite ugly, but it works...
const cookieConfig:NgcCookieConsentConfig = {
cookie: {domain: 'localhost'},
elements: {messagelink: `
<span id="cookieconsent:desc" class="cc-message">{{message}}
<a id="cookieconsent:link" aria-label="learn more about cookies" tabindex="0" class="cc-link">{{link}}</a>
</span>
`}
};
this.ccService.init (cookieConfig);
document.getElementById('cookieconsent:link').addEventListener('click', (e) => this.router.navigate(['/fr/cookies']));
from ngx-cookieconsent.
Ok, I finally figured it out.
Angular 8.
My scenario:
I developed an app with routing navigation, imported and configured CookieConsent to display banner and cookie page link in it. On localhost:4200 all is ok but when I uploaded app on webserver I redeived 404 page by attempting to show the page with the disclaimer (http://mysite/cookie).
So I resolved by using useHash: true in my @NgModule and href: "#/cookie" (with hash) in my href config and now all works fine (http://mysite/#/cookie).
// src/app/app-routing.module.ts
@NgModule({
imports: [RouterModule.forRoot(routes, {useHash: true})],
...
})
// src/app/app.module.ts
const cookieConfig:NgcCookieConsentConfig = {
...
content: {
dismiss: 'OK',
message: 'message text here',
link: 'link text here',
href: "#/cookie"
}
};
hope it helps
from ngx-cookieconsent.
I got one.
First read more here: https://tinesoft.github.io/ngx-cookieconsent/doc/
and
Routes:
{ path: ":lang/cookies-policy", component: CookiesPolicyComponent, },
Module Declaration with hashes
@NgModule({ imports: [RouterModule.forRoot(routes, {useHash: true})], exports: [RouterModule] })
and App Module cookie config:
[...], elements:{ messagelink: ' <span id="cookieconsent:desc" class="cc-message">{{message}} <a aria-label="learn more about cookies" tabindex="0" class="cc-link" href="{{cookiePolicyHref}}" target="_self">{{cookiePolicyLink}}</a>, </span> ', }, content: { target: "_self", cookiePolicyLink: 'Cookie Policy', cookiePolicyHref: '#/${navigator.language}/cookies-policy', },
Remember, only target="_self" in this case.
It will workπ
from ngx-cookieconsent.
Hi @Fluuub ,
This is a valid request indeed. Have you try overriding the HTML element that defines that link? (via link sub-property of elements property inside NgcCookieConsentConfig object)?
const cookieConfig:NgcCookieConsentConfig = {
cookie: {
domain: 'localhost' // or 'your.domain.com'
},
elements: {
link: '<a aria-label="learn more about cookies" tabindex="0" class="cc-link" routerLink="/your-cookie-policy-route">{{link}}</a>'
}
};
Try that and tell me if it works for you.
from ngx-cookieconsent.
Thanks tinesoft, but unfortunate...
Just tried to change elements.messagelink w/ your suggestion but routerLink is just ignored...
from ngx-cookieconsent.
ok, i'll have a closer look tonight.
Stay tuned!
from ngx-cookieconsent.
Any other workaround apart from using JavaScript?
from ngx-cookieconsent.
Related Issues (20)
- [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
- How to set consent? How to prevent popup opening after setting cookie? 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.