angular2-pipe

Angular2: custom pipe could not be found

风流意气都作罢 提交于 2019-11-30 10:40:40
The built-in pipe is work,but all custom pipes that i wanna use are the same error: the pipe 'actStatusPipe' could not be found [ERROR ->]{{data.actStatus | actStatusPipe}} I have tried two ways,declare it in app.module's declarations: app.module.ts: import {ActStatusPipe} from '../pipe/actPipe' @NgModule({ declarations: [ AppComponent, HomePage, ActivitiesList, ActStatusPipe ], ... }) or use other module to declare and export all my pipes: //pipe import {ActStatusPipe} from "./actPipe" @NgModule({ declarations:[ActStatusPipe], imports:[CommonModule], exports:[ActStatusPipe] }) export class

Decimal Pipe in Angular 2 - Commas Only, No Decimal Places

情到浓时终转凉″ 提交于 2019-11-29 18:20:59
问题 I currently use this pipe {{ product.productPrice | number:'.2-2' }} And result is 1,000,000.00 but I want to remove the .00 How do you do that? 回答1: Use this : {{product.productPrice | number: '1.0-0'}} 1.0-0 means: at least one digit before decimal point, 0 digits after decimal point. https://angular.io/api/common/DecimalPipe 来源: https://stackoverflow.com/questions/45955101/decimal-pipe-in-angular-2-commas-only-no-decimal-places

Angular2: custom pipe could not be found

独自空忆成欢 提交于 2019-11-29 16:35:00
问题 The built-in pipe is work,but all custom pipes that i wanna use are the same error: the pipe 'actStatusPipe' could not be found [ERROR ->]{{data.actStatus | actStatusPipe}} I have tried two ways,declare it in app.module's declarations: app.module.ts: import {ActStatusPipe} from '../pipe/actPipe' @NgModule({ declarations: [ AppComponent, HomePage, ActivitiesList, ActStatusPipe ], ... }) or use other module to declare and export all my pipes: //pipe import {ActStatusPipe} from "./actPipe"

How to set locale for numbers in angular 2.0

浪子不回头ぞ 提交于 2019-11-29 11:04:22
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 I have to implement my own pipe? Try using the locale-number .pipe.ts or you could create a simple pipe based on NumeralJs to format numbers https://github.com/adamwdraper/Numeral-js If you only need one locale for your app, you can as of now (@angular ~2.4.0) register the locale provider in @NgModule. @NgModule({ ... providers: [ {provide: LOCALE

Get currency symbol angular 2

℡╲_俬逩灬. 提交于 2019-11-29 07:10:12
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 formatted. Normal situation $3.00 I want only the $symbol , not the number As I ONLY wanted the symbol for the currency, I ended up extending currency pipe with a constant number and return only the symbol. It feels sort of a "hack" to have a constant number, but as i don't want to create new currency maps and I'm not able to provide a number, i think is the

Angular 2: Using pipes with ngModel

牧云@^-^@ 提交于 2019-11-29 04:19:19
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 back to the component. After struggling with this for a while I figured using Angular 2's pipes would be a good solution, however I can't figure out how to get those two to work together either. Here is some code I am using for testing my pipe <input [(ngModel)]="Amount" id="Amount" name="Amount" class="form-control" type="number" autocomplete="off

invoke pipe during run time using pipe name /metadata

眉间皱痕 提交于 2019-11-28 09:28:19
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 <tbody> <tr *ngFor="let row of data"> <template ngFor let-cell [ngForOf]=row> <td *ngIf="cell.pipe">{{cell.content | cell.pipe}}</td> <td *ngIf="!cell.pipe">{{cell.content}}</td> </tr> </tbody> I understand that this example gives an error. Can i use Reflect is some manner or some other solution? You can't apply pipes dynamically. What you can do is to build a "meta"

Angular 2 Pipe under condition

こ雲淡風輕ζ 提交于 2019-11-28 06:42:02
Is it possible in Angular 2 to apply a pipe under condition? I would like to do something like: {{ variable.text | (variable.value ? SomePipe : OtherPipe) }} If not, what is the preferred way to achieve this effect? You need to change the syntax a bit: {{variable.value ? (variable.text | SomePipe) : (variable.text | pipe2)}} Plunker example Since such syntax isn't supported, I think that the only way to do that is to implement another pipe to handle the condition: @Pipe({ name: 'condition' }) export class ConditionPipe { transform(val,conditions) { let condition = conditions[0]; let

How to set locale for numbers in angular 2.0

孤街醉人 提交于 2019-11-28 03:52:09
问题 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 I have to implement my own pipe? 回答1: Try using the locale-number.pipe.ts or you could create a simple pipe based on NumeralJs to format numbers https://github.com/adamwdraper/Numeral-js 回答2: If you only need one locale for your app, you can as of

Get currency symbol angular 2

元气小坏坏 提交于 2019-11-27 18:38:35
问题 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 formatted. Normal situation $3.00 I want only the $symbol , not the number 回答1: As I ONLY wanted the symbol for the currency, I ended up extending currency pipe with a constant number and return only the symbol. It feels sort of a "hack" to have a constant number