angular2-pipe

Angular2 Using Pipes in Component.js

爱⌒轻易说出口 提交于 2021-01-26 06:17:12
问题 I'm learning Angular2 and I want to format a number adding thousand comma separator. As far as I have read this can be done using Pipes, the thing is that I want to format the number programmatically in the js file not in html (doing like var | number). First of all I've realized there is no NumberPipe standalone pipe that I can work with (correct me if I'm wrong) the most similar one is CurrencyPipe in @angular2/common. So I have something like this: import { Component } from '@angular/core'

Angular2 Using Pipes in Component.js

笑着哭i 提交于 2021-01-26 06:15:59
问题 I'm learning Angular2 and I want to format a number adding thousand comma separator. As far as I have read this can be done using Pipes, the thing is that I want to format the number programmatically in the js file not in html (doing like var | number). First of all I've realized there is no NumberPipe standalone pipe that I can work with (correct me if I'm wrong) the most similar one is CurrencyPipe in @angular2/common. So I have something like this: import { Component } from '@angular/core'

Angular2 Using Pipes in Component.js

你离开我真会死。 提交于 2021-01-26 06:11:06
问题 I'm learning Angular2 and I want to format a number adding thousand comma separator. As far as I have read this can be done using Pipes, the thing is that I want to format the number programmatically in the js file not in html (doing like var | number). First of all I've realized there is no NumberPipe standalone pipe that I can work with (correct me if I'm wrong) the most similar one is CurrencyPipe in @angular2/common. So I have something like this: import { Component } from '@angular/core'

Angular2 Using Pipes in Component.js

谁说我不能喝 提交于 2021-01-26 06:10:46
问题 I'm learning Angular2 and I want to format a number adding thousand comma separator. As far as I have read this can be done using Pipes, the thing is that I want to format the number programmatically in the js file not in html (doing like var | number). First of all I've realized there is no NumberPipe standalone pipe that I can work with (correct me if I'm wrong) the most similar one is CurrencyPipe in @angular2/common. So I have something like this: import { Component } from '@angular/core'

Angular 2 Table Search Pipe Filter not working

梦想与她 提交于 2020-02-02 13:46:49
问题 I am creating a table component in Angular 2, in which I am creating a common table search filter pipe, it is working correctly but not displaying the values in their appropriate columns. When I start typing the search keys in the text box the filtered values are displayed correctly but not under their appropriate columns. Sorry if this question is a duplicated one, I have spent enough time in searching the web but I was unable to get a solution for it. Below is the code for your reference

How can I write an Angular ngFor pipe to filter array of objects by object property?

天大地大妈咪最大 提交于 2020-01-23 07:54:22
问题 I have 2 selects. One for Leagues and one for Divisions I want to create a Pipe that will filter Divisions depending on what League is selected. Giving the data below. If I select Random Beer League only TwoFour and SixPack should show up as options for the Divisions select. leagues = [ {id: 1, leagueName: 'Recreation League' }, {id: 2, leagueName: 'Random Beer League' } ]; divisions = [ {id: 1, divisionName: 'SoGreen', leagueId: 1, leagueName: 'Recreation League' }, {id: 2, divisionName:

angular2 add “Read More” link to custom pipe

℡╲_俬逩灬. 提交于 2020-01-15 08:52:09
问题 I have created custome summary pipe class it works fine but I want to add a read more link end of substring.. when clicked all content shown. import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'summary' }) export class SummaryPipe implements PipeTransform { transform(value: string, maxWords: number) { if (value) return value.substring(0, maxWords) +"... <a href='#' (click)='getAllText()'>Read more</a>"; } getAllText() { //return this.value; ? } } I need to fill fucn I know but

Angular2 dynamic pipe

风流意气都作罢 提交于 2020-01-05 05:06:11
问题 I'm using a pipe to internationalize my app: import {Pipe, PipeTransform} from '@angular/core'; import {I18nService} from './i18n.service'; @Pipe({ name: 'i18n' }) export class I18nPipe implements PipeTransform { constructor(private i18nService: I18nService) { } transform(value: any, args?: any): any { return this.i18nService.get(value); } } This pipe calls a service: import {Injectable} from '@angular/core'; const i18n = { en: { hello: 'Hello' }, fr: { hello: 'Salut' } }; @Injectable()

angular2 pipe for multiple arguments

[亡魂溺海] 提交于 2020-01-04 01:51:27
问题 I have a array of thread objects, each thread object with the properties unit:number task:number subtask:number I want to create a pipe to filter after these threads, so far I have a working pipe like below. I'm not really satisfied with it yet and wanted to ask you guys if there is a more elegant solution? HTML: <div class="thread-item" *ngFor="#thread of threadlist | threadPipe:unitPipe:taskPipe:subtaskPipe"></div> Pipe.ts export class ThreadPipe implements PipeTransform{ threadlistCopy

angular2 pipe for multiple arguments

荒凉一梦 提交于 2020-01-04 01:51:09
问题 I have a array of thread objects, each thread object with the properties unit:number task:number subtask:number I want to create a pipe to filter after these threads, so far I have a working pipe like below. I'm not really satisfied with it yet and wanted to ask you guys if there is a more elegant solution? HTML: <div class="thread-item" *ngFor="#thread of threadlist | threadPipe:unitPipe:taskPipe:subtaskPipe"></div> Pipe.ts export class ThreadPipe implements PipeTransform{ threadlistCopy