Skip to content

Instantly share code, notes, and snippets.

View Walgermo's full-sized avatar
🫶
Working on the next thing …

Stian Walgermo Walgermo

🫶
Working on the next thing …
  • Sticos / Walgtech
  • Trondheim, Norway
View GitHub Profile
@Walgermo
Walgermo / readingtime.pipe.ts
Created May 24, 2018 06:10
Angular 2+ reading time pipe
import { Pipe, PipeTransform } from '@angular/core';
/*
* Show total reading time for an text
* Takes an input parameter text.
* Usage:
* value | readingtime
* Example:
* {{ This is a content of my blog post | readingtime }} min read.
* formats to: 1 min read.
*/
@Walgermo
Walgermo / striphtml.pipe.ts
Created May 24, 2018 06:16
Angular 2+ strip html pipe
import { Pipe, PipeTransform } from '@angular/core';
/*
* Strips HTM
* Takes an input parameter HTML.
* Usage:
* content | striphtml
* Example:
* <p [innerHTML]="content | striphtml"></p>
*/
@Pipe({
@Walgermo
Walgermo / truncatetext.pipe.ts
Created May 24, 2018 06:20
Angular 2+ truncate text pipe
import { Pipe, PipeTransform } from '@angular/core';
/*
* Truncates an text with defined cut off length
* Takes an input parameter string.
* Usage:
* string | truncatetext: 100
* Example:
* <p>{{ string | truncatetext: 100 }}></p>
*/
@Pipe({
@Walgermo
Walgermo / safe.pipe.ts
Created May 24, 2018 06:24
Angular 2+ safe content pipe
import { Pipe, PipeTransform } from '@angular/core';
import {
DomSanitizer,
SafeHtml,
SafeStyle,
SafeScript,
SafeUrl,
SafeResourceUrl
} from '@angular/platform-browser';
/*
@Walgermo
Walgermo / meta.service.ts
Last active January 22, 2021 20:33
Angular 6 - Globally set meta title in app on route change
import { Injectable } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { filter, map, mergeMap } from 'rxjs/operators';
/**
* Call updateTitle() from app.component.ts contructor.
* Example app.component.ts:
constructor(private meta: MetaService) {
this.meta.updateTitle();