Code Monkey home page Code Monkey logo

Comments (8)

lovetodream avatar lovetodream commented on June 12, 2024 4

Any updates?
Facing the same "problem" with my application right now. I think that would be a great enhancement

from ngx-cookieconsent.

Fluuub avatar Fluuub commented on June 12, 2024 2

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}}&nbsp;
               <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.

 avatar commented on June 12, 2024 2

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.

Bosper avatar Bosper commented on June 12, 2024 1

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.

tinesoft avatar tinesoft commented on June 12, 2024

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.

Fluuub avatar Fluuub commented on June 12, 2024

Thanks tinesoft, but unfortunate...
Just tried to change elements.messagelink w/ your suggestion but routerLink is just ignored...

from ngx-cookieconsent.

tinesoft avatar tinesoft commented on June 12, 2024

ok, i'll have a closer look tonight.

Stay tuned!

from ngx-cookieconsent.

asad-c avatar asad-c commented on June 12, 2024

Any other workaround apart from using JavaScript?

from ngx-cookieconsent.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.