-
Notifications
You must be signed in to change notification settings - Fork 483
question: Understanding how to use IsBrowser #628
Comments
hey, you're looking for microsoft/TypeScript#7753 3rd party modules can take advantage of this to split code. isBrowser is only meant to be used in application code |
Thanks for the help ! Although I couldn't manage to apply it to my current code. However I managed it this way.
I though importing the non universal 3rd party library would be in my service would be a trouble but it doesn't matter. It matter where is imported the library in the modules, so in this case only in browser.module.ts Hope this can help working around non universal modules ! |
Nicely done @julienR2 ! |
Thanks :) Indeed this workaround could be useful for a lot of 3rd party library. I could make a PR updating the doc with this use-case if you judge it necessary ! |
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. |
Hi !
I'm using a 3rd party library ng2-ui-auth to handle the authentication by providers. However since the library create a popup, it use a lot of window element which doesn't exist on server side.
Luckily I actually don't need it at all on server side since the library is used only on the client. So declared the module Ng2UiAuthModule in app.browser.module and wanted to use isBrowser in my component like this:
However ts states that a import declaration must be in a namespace or module. So after compiling successfully, when I get to the page I encounter "ng2_ui_auth_1 is not defined". Probably because it did get imported because it was not in the module directly isn't it ?
Do you have some advice on this kind of workaround for 3rd party library ? What is the proper way to use IsBrowser to conditionally import a service ?
Thanks for you help !
The text was updated successfully, but these errors were encountered: