Comments (3)
Thanks! Is a bug for universal. I try to fix this.
from ngx-metrika.
Hello, I solved this problem to add that:
// START fix for dom manipulations
// This code was copied from stackOverFlow and don't analyzed
const domino = require('domino')
const fs = require('fs')
const path = require('path')
const template = fs.readFileSync('dist/browser/index.html').toString()
const win = domino.createWindow(template)
global['window'] = win
global['document'] = win.document
global['DOMTokenList'] = win.DOMTokenList
global['Node'] = win.Node
global['Text'] = win.Text
global['HTMLElement'] = win.HTMLElement
global['navigator'] = win.navigator
// END fir for dom manipulations
And also I used 'isBrowser' in my components where I use reach goal.
But I think that is not true solution for everyone. Maybe you should to add some conditions that general module doesn't start if it is server?
Sorry for my bad English
from ngx-metrika.
Hello,
Many thanks for providing this plugin! I currently encounter the same issue and it seems the bug is open since a few years now. Are there any plans for a fix?
In the meanwhile I used the following (ugly) workaround to inject the service conditionally only on client side code.
Pre-rendered file generation works fine with Angular Universal by using:
export class AppComponent implements OnInit {
private ym: NgxMetrikaService;
constructor(private injector: Injector, @Inject(PLATFORM_ID) private platformId: Object) {
// Client only code. Workaround for Angular Universal
if (isPlatformBrowser(this.platformId)) {
this.ym = <NgxMetrikaService>this.injector.get(NgxMetrikaService);
}
}
I hope it helps.
Cheers.
from ngx-metrika.
Related Issues (8)
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-metrika.