-
-
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
Not working with universal (angular 6+) #18
Comments
Hi @alo Thanks for creating the issue. However can you elaborate on the exact problem your are facing with this library and universal? i mean: what command did you run? what is the stacktrace? any other repro steps will be useful.... |
@alo, I was running into the same issue. I followed the instructions on adding everything to the module, but also had to add the injector to the root |
Thanks @zackarychapple. That's it. Even if you don't use it, you have to add the injector to the root @tinesoft is it enough information for you or can I help you with something? |
Here is my workaround : import { Component, Injector, Inject, PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser } from '@angular/common';
import { NgcCookieConsentService } from 'ngx-cookieconsent';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
constructor(
@Inject(PLATFORM_ID) private readonly platformId: Object,
private readonly injector: Injector
) {}
ngOnInit() {
super.ngOnInit();
if (!isPlatformBrowser(this.platformId)) {
return;
}
const ccService = this.injector.get(NgcCookieConsentService);
// Configure stuff
// ...
ccService.init(ccService.getConfig());
}
} |
If you Import NgcCookieConsentService as you did, it will trigger this error :
but if you do create an Injectable :
and then simply import it in your app.component (also put it as a parameter on the constructor) & app.module . This worked for me. Edit* : |
I I have same issue, but i could not been able to solve it. I am running angular universal 10 with following command: And i am getting following error: Please your help, since i am following everything you mention in documentation. Thanks in advance. |
did you manage to fix this error in the end? I'm running into the same error |
Hello, Do you have this problem? |
Hi,
"ngx-cookieconsent": "^2.2.3", |
Hi TGihan, were you able to resolve this |
Bug Report or Feature Request (mark with an
x
)OS and Version?
macOS High Sierra
Versions
Mention any other details that might be useful
It's not working with universal. I've seen similar issues with other modules.
This could help... valor-software/ngx-bootstrap#2369 (comment)
The text was updated successfully, but these errors were encountered: