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
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class CarsService { | |
const userLanguage: LanguageShortName; | |
constructor( | |
private languageService: LanguageService, | |
) { | |
this.userLanguage = this.languageService.getLanguage('en'); |
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
@NgModule({ | |
imports: [ | |
// The AppServerModule should import your AppModule followed | |
// by the ServerModule from @angular/platform-server. | |
AppModule, | |
ServerModule, | |
ServerTransferStateModule, | |
NoopAnimationsModule | |
], | |
providers: [ |
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
@NgModule({ | |
imports: [ | |
... | |
], | |
declarations: [ | |
... | |
], | |
// Providers that are different between the Server and the Browser | |
providers: [ | |
... |
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 { Inject, Injectable } from '@angular/core'; | |
import { LanguageService, LanguageShortName } from 'somewhere'; | |
import { REQUEST } from '@nguniversal/express-engine/tokens'; | |
import { Request } from 'express'; | |
@Injectable() | |
export class ServerLanguageService extends LanguageService { | |
constructor(@Inject(REQUEST) private request: Request) { | |
super(); | |
} |
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 { LanguageService, LanguageShortName } from 'somewhere'; | |
@Injectable() | |
export class WebLanguageService extends LanguageService { | |
constructor() { | |
super(); | |
} | |
getLanguage(defaultLanguage: LanguageShortName): LanguageShortName { |
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 { LanguageShortName } from '../models/language-short-name'; | |
export abstract class LanguageService { | |
readonly SUPPORTED_LANGUAGES: LanguageShortName[] = ['nl', 'en', 'sv', 'de']; | |
public abstract getLanguage(defaultLanguage: LanguageShortName): LanguageShortName; | |
} |
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 } from '@angular/core'; | |
import { Observable } from 'rxjs'; | |
import { StatusCodeResponseService } from './status-code-response.service'; | |
import { HttpClient, HttpErrorResponse } from '@angular/common/http'; | |
import { environment } from '@env/environment'; | |
import { Observable, throwError } from 'rxjs'; | |
import { catchError } from 'rxjs/operators'; | |
@Injectable({ | |
providedIn: 'root' |
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 { NgModule } from '@angular/core'; | |
import { StatusCodeResponseService } from './status-code-response.service'; | |
@NgModule({ | |
providers: [StatusCodeResponseService], | |
}) | |
export class CoreModule {} |
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 { Inject, Injectable, Optional } from '@angular/core'; | |
import { RESPONSE } from '@nguniversal/express-engine/tokens'; | |
import { Response } from 'express'; | |
@Injectable() | |
export class StatusCodeResponseService { | |
private response: Response; | |
constructor( | |
@Optional() |
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
// Can be run with a file like this: | |
// node convert-to-jest.js src/app/home/search/search.component.spec.ts | |
var fs = require('fs'); | |
var filename = process.argv[2]; | |
if (!filename) { | |
let specs = require('glob').sync('src/**/*.spec.ts'); | |
for (spec of specs) { | |
if (!spec.includes('pact')) { |
NewerOlder