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
const CACHE_IT = new HttpContextToken<boolean>(() => false); | |
export function cacheIt() { | |
return new HttpContext().set(CACHE_IT, true); | |
} | |
@Injectable() | |
export class CacheInterceptor implements HttpInterceptor { | |
intercept(request: HttpRequest, next: HttpHandler): Observable<HttpEvent> { |
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"; | |
export enum LogLevel { | |
DEBUG, | |
INFO, | |
ERROR, | |
} | |
@Injectable() | |
export class LogService { | |
minimumLevel: LogLevel = LogLevel.INFO; | |
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
private itersection(textOne: string, textTwo: string): string { | |
let textOneIndex: number = 0; | |
let textTwoIndex: number = 0; | |
let matchedText: string = ''; | |
textOne = textOne.toLowerCase(); | |
textTwo = textTwo.toLowerCase(); | |
while (textOneIndex < textOne.length && textTwoIndex < textTwo.length) { | |
if (textOne[textOneIndex] < textTwo[textTwoIndex]) { |
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
const { writeFileSync } = require('fs') | |
const { join } = require('path') | |
const BUILD_DATE_TIME_STAMP_PATH = join(__dirname, 'build-date.json'); | |
const createBuildDate = { | |
buildDate: new Date() | |
} | |
writeFileSync(TIME_STAMP_PATH, JSON.stringify(createBuildDate, null, 2)); |
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 { Component, HostListener, OnInit } from '@angular/core'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent { |
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 { MatSnackBar } from '@angular/material/snack-bar'; | |
import { SwUpdate } from '@angular/service-worker'; | |
@Injectable() | |
export class UpdateService { | |
constructor(private swUpdate: SwUpdate, | |
private snackbar: MatSnackBar) { | |
this.swUpdate.available.subscribe(event => { |
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 { FormControl } from "@angular/forms"; | |
export function noWhitespaceValidator(control: FormControl) { | |
const isWhitespace = (control.value || '').trim().length === 0; | |
const isValid = !isWhitespace; | |
return isValid ? null : { 'whitespace': true }; | |
} |
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 { BehaviorSubject, Observable } from 'rxjs'; | |
import { TranslateService } from '@ngx-translate/core'; | |
import { DOCUMENT } from '@angular/common'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class LanguageService { | |
private readonly DEFAULT_LANGUAGE = '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
<input type="text" autocomplete="off" autocomplete="chrome-off"> |
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
<!-- keep it as text to hide arrow up and down --> | |
<!-- user can add negative numbers if type number --> | |
<input type="text" positiveNumbers> |
NewerOlder