angular2-universal-starter
angular2-universal-starter copied to clipboard
Universal setTitle
Does it and it means that there is no Universal Title service yet?
This code crashes while building server bundle.
import { Title } from 'angular2/platform/browser';
./node_modules/angular2/src/facade/browser.js:4 var win = window; ^ ReferenceError: window is not defined
Just ran into it as well...not sure if it's a bug or just not recommended to use with Universal/Web Workers.. however, the app still seems to not load even if I turn off WW and SS in the constants and have Title in the providers.
@vaseker There are no Title services for web workers nor for server side at the moment. I can implement them temporary in this starter (I'll do it after #51 is merged).
@qdouble Hmm.. I think it's bug. The application should work if you turn off server side and web workers. But at the same time you should not use import { something } from 'angular2/platform/browser' for your components, you should use it only in boot_browser file. All code in your angular2 components should be absolutely environment agnostic.
As I've said I'll solve the issue after #51.
@alexpods thanks for explanation. +1 for Universal Title service after #51 merged)
https://github.com/angular/angular/blob/master/modules/angular2/src/platform/browser/title.ts
@gdi2290 Thanks that helped.
Edit: It works like normal, I just made a mistake. Thanks again.
It doesn't work to set title in web workers though unfortunately.
Related: https://github.com/angular/angular/issues/7301
Could it be implemented now with your commit to universal by any developer? Could you give some examples of how it can be implemented manually, while core team doesn't have that service?
@Settler See simple implementation here. It should work for every environment that mocks real document (DOCUMENT service). You have to use renderDocumentWithPreboot instead of renderToStringWithPreboot here to make it work.