This service assumes that you followed the SSR receipt at ng-cli (i.e. you use the '@nguniversal/express-engine' package).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* When manually subscribing to an observable in a view component, developers are traditionally required | |
* to unsubscribe during ngOnDestroy. This utility method auto-configures and manages that relationship | |
* by watching the DOM with a MutationObserver and internally using the takeUntil RxJS operator. | |
* | |
* Angular 7 has stricter enforcements and throws errors with monkey-patching of view component life-cycle methods. | |
* Here is an updated version that uses MutationObserver to accomplish the same goal. | |
* | |
* @code | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const { readFile, writeFile } = require('fs'); | |
const { join } = require('path'); | |
readFile(join(__dirname, '../dist-server/main.bundle.js'), 'utf-8', (err, data) => { | |
if(err) { return console.log('Error reading file:', err); } | |
const ssrPageScrollBundle = 'ng2-page-scroll/bundles/ng2-page-scroll.umd.js' | |
const newCode = data.replace('ng2-page-scroll', ssrPageScrollBundle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { Observable } from 'rxjs/Observable'; | |
import * as io from 'socket.io-client'; | |
@Injectable() | |
export class SocketService { | |
socket: any; | |
private host: string = `${window.location.protocol}//${window.location.hostname}:${window.location.port}`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global['document'] = { | |
createElement() { | |
return { | |
setAttribute: function(type) { this.type = type; }, | |
type: '', | |
classList: { add: () => undefined } | |
}; | |
}, | |
documentElement: { | |
getBoundingClientRect: () => ({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, Optional, Inject } from '@angular/core'; | |
import { APP_BASE_HREF } from '@angular/common'; | |
import { NodePlatformLocation, REQUEST_URL, ORIGIN_URL } from 'angular2-platform-node'; | |
import { Response, Request } from 'express'; | |
/** | |
* Issue HTTP 302 redirects on internal redirects | |
*/ | |
@Injectable() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable, Inject } from '@angular/core'; | |
import { DomAdapter } from '@angular/platform-browser/src/dom/dom_adapter'; | |
import { __platform_browser_private__, DOCUMENT} from '@angular/platform-browser'; | |
@Injectable() | |
export class SeoService { | |
private _dom: DomAdapter = __platform_browser_private__.getDOM(); | |
constructor(@Inject(DOCUMENT) private _document: any) { } | |
setTitle(title: string) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license | |
* Copyright Google Inc. All Rights Reserved. | |
* | |
* Use of this source code is governed by an MIT-style license that can be | |
* found in the LICENSE file at https://angular.io/license | |
*/ | |
import { Injectable, Inject } from '@angular/core'; | |
import { DomAdapter } from '@angular/platform-browser/src/dom/dom_adapter'; | |
import { __platform_browser_private__, DOCUMENT} from '@angular/platform-browser'; |
- Users want to compose reducer tree across modules
- Idea of a single reducer function makes it difficult for the library to dynamically augment the shape of the state tree
- Turning control over to the library to build the root reducer limits the use of meta-reducers
- Feature modules may inadvertently collide with the state of the root module
- Library authors may want to leverage @ngrx/store in their projects and provide an easy way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
selector: '[universalAd],[universal-ad]' | |
}) | |
class UniversalAd { | |
constructor( | |
@Attribute('id') public id: string, | |
public adRegistry: MyAdRegistry, | |
public elementRef: ElementRef, | |
public cdRef: ChangeDetectorRef) { |
NewerOlder