angular-universal

Angular Universal - How to trigger manually the state change from server side to client view?

最后都变了- 提交于 2019-12-06 07:42:36
We have a simple Angular Universal app using angular/cli: 1.4.3 (and node: 6.9.5). We manage to configure the server side view. When the dom is ready, we switch to a client view. But, the switch is made before we collect all the data needed from the API. So there is a moment right after the switch when the page is displayed without the data. Is there any way to trigger manually the switch between the 2 states? In this case, we want to display the client view after we get the response from the API. Here is the simplified example we made for this: import { Component, OnInit } from '@angular/core

Why postcss-merge-rules vesion give me an error Angular 5 - Webpack

不羁的心 提交于 2019-12-06 06:31:24
问题 Error with postcss plugin This a log when I tried a ng build --prod, I' using angular universal only give me that error with bootstrap and font-awesome. 10% building modules 4/6 modules 2 active ...ules/bootstrap/dist/css/bootstrap.cssUnknown error from PostCSS plugin. Your current PostCSS version is 6.0.17, but postcss-merge-rules uses 5.2.18. Perhaps this i 55% building modules 380/383 modules 3 active ...ules/bootstrap/dist/css/bootstrap.cssUnknown error from PostCSS plugin. Your current

How to use localStorage in angular universal?

断了今生、忘了曾经 提交于 2019-12-05 18:27:53
I am using @angular v4.0.3 and webpack 2.2.0. It was working fine using Auler post but as I included localStorage it stopped working. Is there any way to make it work or any module for localStorage in angular universal A good way is to make localStorage an injectable and provide different implementations for it. An abstract class that reflects Storage API can be used as a token: export abstract class LocalStorage { readonly length: number; abstract clear(): void; abstract getItem(key: string): string | null; abstract key(index: number): string | null; abstract removeItem(key: string): void;

Component CSS Disappears from Components During App Bootsrapping With Preboot

為{幸葍}努か 提交于 2019-12-05 12:42:27
My beautiful server-side rendered Angular 5 application (using Universal with a node express.js server) is having problems with styling during the bootstrap (preboot) phase. The global CSS stylesheet seems to be fine, but the component-specific styles disappear once bootstrapping begins. Example: Component styling with javascript disabled (pure html and css from the server): Component styling with javascript enabled and before app starts bootstrapping (still fine, still pure html and css from the server): Component styling during bootstrapping transition phase (terrible because the component

Angular5 Server side rendering, external Api data service does not work in ssr

感情迁移 提交于 2019-12-05 12:00:32
I have setup and used successfully Angular5 + SSR. It is still pretty nice. All components works well on SSR and Non-SSR. And there are some services which calls external HTTP get apis to get some data. Of course it work well on a Non-SSR mode. But, the problem is that on SSR, node server does dot support to fetch and render the data. I can only see the fetched data after client side fetching and rendering. import {Injectable} from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import 'rxjs/add/operator/map'; import {Observable} from "rxjs"; const httpOptions

How implement SEO (Metatags) in Angular 2 (with Angular universal for rendering on server side)?

半腔热情 提交于 2019-12-05 05:04:25
I'm searching a fully working example about SEO or Metatags with Angular 2 using Angular universal to render on server side (to be recognize by facebook, twiter, and other metatags) but I had not success.. I found multiple articles, but there are incomplete (no all source code is available) or oldest (not compile with the latest versions): a) blog.devcross.net/2016/04/17/angular-2-universal-seo-friendly-website/ NOTE: Excelent post with source code, but It's not working. b) builtvisible.com/universal-angular-2-server-side-rendering-seo-crawl-friendliness/ NOTE: Very usefull but with no source

Angular Universal server rendering WebSocket

回眸只為那壹抹淺笑 提交于 2019-12-05 05:02:49
Are there any examples of Angular Universal with WebSockets? Serverside rendering does not know wat a WebSocket object is in my case. And if I use socket.io the node server hangs when trying to make a connections. Some additional information about the problem: I downloaded angular-universal-starter from github: https://github.com/angular/universal-starter Which works fine out of the box running 'npm install' and 'npm start' But after i added the following code to AppComponent export class AppComponent implements OnInit { ngOnInit() { let webSocket = new WebSocket("----server url----") } } I

window is not defined angular universal third library

余生长醉 提交于 2019-12-05 04:02:49
问题 I am working with the library ng2-mqtt and I used it im my component like this: import 'ng2-mqtt/mqttws31.js'; declare var Paho: any; Now I am getting following error: ReferenceError: window is not defined at Object.<anonymous> (/Users/Picchu/Documents/em3/node_modules/ng2-mqtt/mqttws31.js:2143:4) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js

Angular Transfer State not preventing repeat http calls

白昼怎懂夜的黑 提交于 2019-12-05 01:51:18
问题 I have the http request being made a service which is injected onto my component and subscribed to from there. Since I introduced server side rendering with angular universal to my application, the results on the page are repeated at least twice. I have method which is called on click, which performs the http request to facebook's api getAlbum(albumId: number) { this.albumPhotos = this.state.get(ALBUM_PHOTOS_KEY, null as any); if (!this.albumPhotos) { this.facebookService

How to deploy angular universal in IIS?

萝らか妹 提交于 2019-12-05 00:52:50
问题 I am facing problem with deploying angular universal application in IIS. In angular universal two dist folder is created one is dist for client and another is dist-server, when I try to host , I am giving path of dist folder ,site is running but pages not rendered from server. 来源: https://stackoverflow.com/questions/46907440/how-to-deploy-angular-universal-in-iis