Skip to content

Instantly share code, notes, and snippets.

@lucabertolasi
lucabertolasi / format-currency.js
Last active March 4, 2018 20:48
[JavaScript] Format currency: from cents<number> to <string> or viceversa (e.g. 120030040 --> "1.200.300,40" --> 120030040).
/**
* @license
* Copyright (c) 2017-present, Luca Bertolasi. All Rights Reserved.
*
* This software is licensed under the terms of the MIT license,
* a copy of which can be found at https://opensource.org/licenses/MIT
*/
function formatCurrency(amount, strToNum) {
// default behaviour:
@Frelseren
Frelseren / custom-url-serializer.ts
Created May 29, 2018 14:13
A custom url serializer for Angular Router to support escape characters
import { UrlSerializer, UrlTree, DefaultUrlSerializer } from '@angular/router';
export class CustomUrlSerializer implements UrlSerializer {
parse(url: any): UrlTree {
const dus = new DefaultUrlSerializer();
return dus.parse(unescape(url));
}
serialize(tree: UrlTree): any {
const dus = new DefaultUrlSerializer();