Skip to content

Commit

Permalink
pipe personalizado
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Guzmán committed Feb 21, 2018
1 parent f2a6f3d commit c2fe356
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/app/pipes/capitalizado.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'capitalizado'
})

export class CapitalizadoPipe implements PipeTransform {
transform(value: string, todas: boolean = true): string {
//console.log(value);
value = value.toLowerCase();
let nombres = value.split(" ");

if (todas) {
for (let i in nombres) {
nombres[i] = nombres[i][0].toUpperCase() + nombres[i].substr(1);
}
}else{
nombres[0] = nombres[0][0].toUpperCase() + nombres[0].substr(1);
}


return nombres.join(" ");
}
}

//Definir en app.module.ts el pipe

0 comments on commit c2fe356

Please sign in to comment.