angular-universal

Angular Transfer State not preventing repeat http calls

白昼怎懂夜的黑 提交于 2019-12-03 16:27:30
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.getBachadiffAlbumPhotos(albumId).subscribe(res => { this.bachataPicsArray = res; this.state.set(ALBUM_PHOTOS_KEY, res as

Using cookies in Universal Rendering using angular-cli

混江龙づ霸主 提交于 2019-12-03 14:22:28
I have made an angular app using angular-cli and doing universal rendering in it by following steps given here . But it is mentioned that i can't use Global variables like window and document in my app if i am doing universal rendering, How can i set cookies at front end to maintain user session. Previously i was using JWT, but for doing that i need to set cookies in my browser. Note: all the information below is only valid if you're using Node with Express to dynamically render (at the time a request hits the server) your Angular app on the server. I haven't looked into pre-rendering. And I

How to make Angular Universal and PWA work together?

ⅰ亾dé卋堺 提交于 2019-12-03 10:09:15
I have a SSR Angular app which I am trying to transform into a PWA. I want it to be server-side rendered for SEO and for the "fast first rendering" that it provides. The PWA mode works fine when combined with SSR, but once the app is loaded, when we refresh it, the client index HTML file is loaded instead of the server-side rendered page. I have dug into the code of ngsw-worker.js and I saw this: // Next, check if this is a navigation request for a route. Detect circular // navigations by checking if the request URL is the same as the index URL. if (req.url !== this.manifest.index && this

Angular 2 Universal - Store Global Variables

坚强是说给别人听的谎言 提交于 2019-12-02 07:11:26
问题 I am trying to convert my AngularJS application to Angular 2 Universal application (because of server-side rendering). https://github.com/angular/universal-starter Now I need to store global variables which could be achieved easily in normal Angular 2 applications(per below links). Angular 2 global variable Angular 2 - Whats the best way to store global variables like authentication token so all classes have access to them? One thing you will have to do to achieve this in normal angular 2 App

Angular universal Server Side Rendering, Meta tags

旧时模样 提交于 2019-12-01 22:15:43
问题 I moved my site to Angular universal SSR, during my move I encountered some problems that I thought ng-universal would fix. I want to add meta tags such as description, keywords etc (different for each page). Using the titleService as angular suggests works just fine, it changed the title of the pages. However if I land on homepage and then navigate from there to other pages, the title is not changing, but when I look on source I see the change in the source but no on the tab of VIEW. If I

Updating meta tags for SEO using angular universal

徘徊边缘 提交于 2019-12-01 21:43:44
I am building an angular universal + angular 2 website and i want to add the social media share button. I implemented the server side rendering and i also update the meta tags necessary using the following code : constructor(private dataService: DataService, private activatedRoute: ActivatedRoute, private auth: AuthService, private router : Router, private meta : Meta) { this.currentUrl = window.location.href; // testing if it changes something to add that outside of the service : it didnt this.meta.updateTag({ property: 'og:title', content: "my new title" }) let id= this.activatedRoute

Angular universal Server Side Rendering, Meta tags

若如初见. 提交于 2019-12-01 21:12:47
I moved my site to Angular universal SSR, during my move I encountered some problems that I thought ng-universal would fix. I want to add meta tags such as description, keywords etc (different for each page). Using the titleService as angular suggests works just fine, it changed the title of the pages. However if I land on homepage and then navigate from there to other pages, the title is not changing, but when I look on source I see the change in the source but no on the tab of VIEW. If I land on the page (or hit refresh) the page is updated with the correct title. I tried to add in

ASP.Net Core 2.1 Angular SSR/Universal returning Http Status Code 404

陌路散爱 提交于 2019-12-01 13:16:33
问题 With SpaPrerenderingExtensions available in ASP.Net core 2.0 JavaScriptServices , it seems that we can return the HTTP Status Code from the Angular (SSR) App which SpaPrerenderingExtensions will use to return the HTTP Status Code to the client. If you take a look at below method in SpaPrerenderingExtensions private static async Task ServePrerenderResult(HttpContext context, RenderToStringResult renderResult) Complete code of SpaPrerenderingExtensions is available here: https://github.com

error using isBrowser function in angular universal

你。 提交于 2019-12-01 00:37:09
I'm trying to use the isBrowser function in angular universal but I keep getting the same error when I build. I did install the npm package of angular-universal npm i angular2-universal --save 'ng build -prod -aot' ERROR in Illegal state: symbol without members expected, but got {"filePath":"C:/dir/universal/website/node_modules/@angular/platform-browser/platform-browser.d.ts","name":"__platform_browser_private__","members":["BROWSER_SANITIZATION_PROVIDERS"]}. ERROR in ./src/main.ts Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'C:/dir/universal/website\src'

How to properly launch Angular Universal to live server

…衆ロ難τιáo~ 提交于 2019-11-29 15:49:52
问题 I have my website setup and working by modifying the universal-starter seed found here: https://github.com/angular/universal-starter and I have got my site working (rendering HTML) on the localhost node server, now I have a SSH connection and node installed, now I am here: And I am not sure where I put my /dist files etc and then start the nodejs server. NodeJS/npm installed shown here: 回答1: This was actually easier than it seemed, I just needed to install pm2 with npm so I could make the