Skip to content

Commit

Permalink
feat(pipes): init pipes
Browse files Browse the repository at this point in the history
  • Loading branch information
pengkobe committed Nov 1, 2018
1 parent 6d8fb98 commit 4876de0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/pipes/pipes.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';

import { StringTruncatemPipe } from './stringTruncate.pipe';

export const pipes = [
StringTruncatemPipe,
];

@NgModule({
declarations: [pipes],
exports: [pipes],
})
export class PipesModule {}
15 changes: 15 additions & 0 deletions src/app/pipes/stringTruncate.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
name: 'StringTruncate'
})
export class StringTruncatemPipe implements PipeTransform {
transform(value?: string, args?: any): any {
const bitnum = args;
if (value && value.length > bitnum) {
return value.substr(0, bitnum) + '...';
} else {
return value;
}
}
}

0 comments on commit 4876de0

Please sign in to comment.