I've to do some initialization for my theme after the view has been initialized.
I've implemented AfterViewInit, I've managed to import jquery:
import * as $ from 'jquery';
But now I need to execute this:
ngAfterViewInit() {
$(document).trigger('nifty.ready');
}
And I've trouble, because it seems that at this point, document is not known. I guess I should have another import, but I can't find from where?
My whole app.component.ts:
import { Component, AfterViewInit } from '@angular/core';
import * as $ from 'jquery';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit {
ngAfterViewInit() {
$(document).trigger('nifty.ready');
}
}
The error I get:
Exception: Call to Node module failed with error: TypeError: Cannot read property 'document' of undefined at module.exports.module.exports (E:\My\Clients\AppClientApp\dist\vendor.js:12879:12) at AppComponent.ngAfterViewInit
EDIT
You can find here the whole web app part.
EDIT2
In fact I've the impression that jquery is not initialized properly at all, once loaded(without error), window.jquery return undefined... any idea why?
$(document)...line, everything is working. I added the whole classimport $ from 'jquery';I usedocumentjust fine insidengOnInitin my appCall to Node module failed with error: ReferenceError: document is not defined