-
Notifications
You must be signed in to change notification settings - Fork 484
List browser global that we need to support in Universal #534
Comments
Polymer would be a nice addition if it's possible. |
Polymer++ |
Also Angular 2 Material |
Supporting |
which properties on |
@rogerpadilla I have material support added to Universal 2.0.5 |
-localstorage |
+1 for localStorage |
XMLHttpRequest |
window.history - navigation document.documentElement.clientWidth - custom lazyload functions, cross browser our 3rd party global libs: Foundation |
3rd party:
|
3rd party:
|
Hi @gdi2290 , you mention that there is a best practice for dealing with 3rd party services, what is it? |
Custom Elements would be interesting. https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements |
|
ace editor comes with brace module
but it introduces other errors in code. |
@gdi2290 Any idea when this might b available? If not can you provide the information on the best practice way of dealing with 3rd party services as at the moment it's a bit of a nightmare trying to integrate certain features. |
@dotoodot At the moment using What are you trying to use? |
@MarkPieszak One example is https://github.com/zefoy/angular2-perfect-scrollbar I'm using DI for some things such as 3rd party scripts which I've kind of got my head round but when it come to things like the above i.e loading a module just for the client I get a bit lost. |
One thing you could try doing is creating a ghost/empty Component directive for it (that you inject in your server NgModule file. You might be able to pull something like that off, if it's real simple, just so that the server completely ignores it. Make sure you don't include the Module for that library in your server NgModule, only do that in the Client part.
You're right though, it would be helpful to document this more thoroughly, it's a bit of a complicated process! |
|
@MarkPieszak How are you doing? I would like to do something similar to @dottodot, except with a window.localstorage service.. there's a nice post here: http://stackoverflow.com/questions/39085632/localstorage-is-not-defined-angular-universal/39098748#39098748 on an approach for using window.localstorage in angular-universal except that it produces an error on the server... details here http://stackoverflow.com/questions/41430971/angular-universal-starter-localstorage-in-production-using-window-in-browser ... I'm sure I'm missing something simple and it sounds like the ghost/empty approach might work... What do you think? Is there a good way to wrap LocalStorage as an 'empty' provider, in node.module.ts so that it doesn't generate an error?
(Many thanks and hope this is the right place for a question like this) |
@owencooney You'd basically want to do a similar thing, so for your main.client providers, make sure While in your main.node list of providers, for that That should do it! That's the gist of dependency injection magic :) |
@MarkPieszak awesome, I'll give that a go! Thanks a mil Mark! |
won't be supported officially |
I just find a workaround to avoid |
I get error |
@MarkPieszak make sure you have both |
Interesting, yeah I tried both. Let me try with a fresh blank repo. |
Doesnt work for me, this generate other errors |
angularfire 2 wont work because XMLHttpRequest not available |
@hiepxanh it is avialable through something like @angular/common/http |
@Toxicable I mean, angular universal won't work with third party library like angularfire 2, when that lib making some request, I have to add: |
In case anyone come here for angular ssr issue, you can use below webpack config for your server ts build. { Similarly: https://medium.com/@puresmash/solve-hammer-js-issue-on-ssr-project-2e79664a7196 @egjs/hammerjs will work also, but it's not working properly with slider on mobile in my project. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The next version of Universal can support/mock any browser global so please list out any of the that are the most important ones for me to make sure you can use it.
Browser
document
document.querySelector
document.querySelectorAll
document.cookie
XMLHttpRequest
fetch
localStorage
navigator
history
location
navigator
localStorage
sessionStorage
window
(please list out which properties you're using onwindow
and how you use it)window.pageYOffset
window.pageXOffset
window.scrollTo
window.addEventListener
Common Libs (with globals)
Research (we need to determine if possible)
Supported (so far)
Twitter Poll
https://twitter.com/gdi2290/status/776893828045246466
The reason for this is to allow faster adoption of Universal JavaScript with components that the developer may or may not have control over
Please leave a comment of a browser global that you use (if
window
make sure to include some of the properties or functions used) and what you're using it for to make it in the next releaseupdate:
added research list
added polymer
The text was updated successfully, but these errors were encountered: