Usage with Angular 6
sapanjwani opened this issue · 3 comments
Your code and the idea is very good. Is there a way to use this with Angular 6 framework . I was trying to make a service which returns the ServerDate.now() ; which can be used by other components and services .
Thanks, Awaiting your help !
Thank you. I'm not familiar with Angular 6 but I don't see why ServerDate couldn't be incorporated into a component. If you try and run into a problem you're welcome to post code here and I can see if I can help.
I added serverDate.js by adding it as a script on document body like this .
loadScript() {
const body = document.body;
const script = document.createElement('script');
script.innerHTML = '';
script.src = '../assets/js/ServerDate.js';
body.appendChild(script);
}
And then used like this.
this.serverDateTimeStamp = (window as any).ServerDate.now();
This seemed working fine for me . Are there any suggestions ? I welcome your suggestions.
Looks good to me. :-)