Questions tagged [angular2-pipe]

An Angular 2 pipe takes in data as input and transforms it to a desired output.

An Angular 2 pipe takes in data as input and transforms it to a desired output.

The first version of AngularJS, used the concept of filters to format the value of an expression for display to the user.

Angular 2 introduced a similar concept, now called pipe.

187 questions
12
votes
5 answers

Get currency symbol angular 2

I'm building an application using angular 2 and currency pipe, but I can't find a way to get the currency symbol according to the ISO value without any number. What I mean is that I just want the symbol without setting a number to be…
soni
  • 687
  • 1
  • 8
  • 23
12
votes
2 answers

Cannot Instantiate DatePipe

I am trying to instantiate a DatePipe object in my Angular2 app to use transform(...) function in a component I'm developing. // ... import { DatePipe } from '@angular/common'; @Component({...}) export class PanelComponent implements OnInit { …
12
votes
4 answers

How to set locale for numbers in angular 2.0

The number format in Swiss German is like "100'000.00" (not "100,000.00"). How can I change that? I tried to change the settings in number_pipe.js from en-US to de-CH without success. var defaultLocale: string = 'de-CH'; Is there a workaround or do…
surfspider
  • 727
  • 3
  • 11
  • 25
10
votes
1 answer

Angular 2: Using pipes with ngModel

I was using JQuery inputmask in one of my forms along with [(ngModel)], but for some reason they won't work together. Using either one by itself works perfectly fine, but combining the two completely breaks [(ngModel)] and new inputs don't get sent…
Bryan
  • 2,951
  • 11
  • 59
  • 101
9
votes
2 answers

Angular2 Using Pipes in Component.js

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 |…
didi3r
  • 227
  • 1
  • 3
  • 11
8
votes
5 answers

Angular 2 Pipe ShortDate on NGX Data Table

I would like to format a date column as a short date in Angular 2 NGX Datatable. Here is the HTML: Here is the component TypeScript import { Component, OnInit } from…
Greg Finzer
  • 6,714
  • 21
  • 80
  • 125
8
votes
1 answer

Angular using pipe from custom one

I would be glad to get some help importing a build-in pipe to a custom one in angular 2. This is my code : @Pipe({ name: 'tablePipe' }) export class TablePipe implements PipeTransform { constructor(private decimalPipe: DecimalPipe) { } …
John Libes
  • 363
  • 3
  • 11
7
votes
2 answers

Accessing result of async pipe in template from component code in Angular 2

In Angular 2 I have a component with a template. In the component TypeScript code i create a Reactive Extensions Observable (items$) and use it in an ngFor-directive in the template with an async-pipe. This way I do not have to worry about…
lox
  • 1,602
  • 4
  • 27
  • 41
6
votes
1 answer

Is there any way to use Angular percent pipe without sign?

I am trying to format the value with percent pipe in html(Angular2) and i need the percentage value without % sign
6
votes
1 answer

Angular: ng build --prod "Cannot determine the module for class. Add class to the NgModule to fix it"

I have placed my pagination logic in a separate module and importing it in AppModule. Below is my code for my pagination module and AppModule. PagingUtilitiesModule: import { NgModule, ModuleWithProviders, Injector } from '@angular/core'; import {…
karthikaruna
  • 3,042
  • 7
  • 26
  • 37
6
votes
1 answer

How to pass function as arg Pipe angular2

I'd like to have a generic fields filter that will get the filter function as an argument and use it in filter import {Injectable, Pipe, PipeTransform} from '@angular/core'; @Pipe({ name: 'FieldsFilter' }) @Injectable() export class FieldsFilter…
naomi
  • 2,583
  • 2
  • 22
  • 39
6
votes
2 answers

How to tell angular (2) currency pipe to display as it is if value is a string not int or float

The currency pipe should be smart enough to handle string, float, int, etc automatically. if passed value is string or not int or float, it should do nothing and display the passed value as it is. And only display formatted value if it is int or…
Aniruddha Das
  • 20,520
  • 23
  • 96
  • 132
6
votes
2 answers

invoke pipe during run time using pipe name /metadata

I'm trying to build a dynamic table where i wand to decide in run time which pipe to use (If Any). I'm trying to achieve something similar to (Simplified): export class CellModel { public content: any; public pipe: string } Table …
royB
  • 12,779
  • 15
  • 58
  • 80
5
votes
1 answer

How to use services in custom pipes in angular 2

I want to display months in years on html. My filter takes number of months as an input and it should return years. For example: if it takes 12 as input, it should return translated value as 1 year. and if it is more than 1 year, it should return…
Prerna Shukla
  • 113
  • 1
  • 9
5
votes
1 answer

Angular 2 PercentPipe unusual output

The following bindings: {{ -50.52338914680037 }} {{ -50.52338914680037 | number }} {{ -50.52338914680037 | percent }} Produce: -50.52338914680037 -50.523 -5,052.339% I would anticipate the output of the percent pipe to be -50.523% Is there…
user3244479
1
2
3
12 13