-
-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always shows in angular universal #88
Comments
Hi @blasco the underlying Maybe using this cookie-parser middleware? |
yes, I would like to have the option of not running the cookie consent automatically (so I can run it only when I check that the code is running on the browser). The problem is that including the module results in the window being shown. Is there await to prevent the automatic init? |
Any way to achieve this? The only thing I need is to init the module only if I'm in the client and not the server, which is easy to detect. The only problem I have is that the init is called when the module is included... is there a way to prevent this? |
It's very weird though, I don't see any cookie being place. Maybe the error has to do with that I'm using Angular 10? |
Hi blasco, one question , did you do something else apart from documentation ??, i could not get it to work in angular 10 universal, so i would really appreciate if you can help me or share me a little of the process of adding this cookieconsent. I am getting following error, while in single page app works great : |
@nilot111 I call the initialization only at the browser. Add a check that you are not on the server side to avoid these errors. |
@blasco thanks, but how can you add that checking if it initialize by itself with just adding in constructor . ?? Following documentation i need to add it to app.component.ts just like this : As my understanding this by itself call initialize, so how can i prevent it only executes in browser since it is in the constructor. thanks in advance. |
@nilot111 I'm not using this library anymore, I don't remember how I made it work, but I think you are right and the init is called in the constructor |
Hi all, Sorry for the late response... The library is indeed automatically initialized in the constructor. I will update to change this behavior or at least configure it in the upcoming release of the library. Stay tuned |
@tinesoft I am glad to hear that you will update. Thank you so much for giving time to this. Regards. |
Did you manage to change this to not automatically call the init method? It would be helpful if you can as I have a production site that needs this to work on using Angular Universal. I'm happy to take a stab at changing if you want, As an alternative solution for anyone else waiting for this, you can use Angular's Injector to conditionally inject into the plugin into the main compponent depending on the presence of a cookie. The below link explains conditional injection. https://stackoverflow.com/questions/43450259/how-to-conditionally-inject-service-into-component |
@tinesoft |
I am also having a similar issue to the one arindamINT explains above - the popup always shows up every time the page loads and clicking "Got It" while using the "info" type does not set any cookie. |
Did you tried it on localhost? |
I tried with both, localhost as well as a staging server. |
@tinesoft |
Bug Report or Feature Request (mark with an
x
)It always shows in angular universal. In the browser version works correctly, but not sure if it needs to be added in a different way when using angular universal. My guess is that the server is rendering it and showing it, even when the user has already accepted it. Any possible solution?
The text was updated successfully, but these errors were encountered: