How to display the currency symbol to the right in Angular

前端 未结 8 1387
花落未央
花落未央 2020-12-15 04:37

I have to display Euro currency like this : 583 €.

But with this code:

{{ price | currency:\'EUR\':true }}

I get

8条回答
  •  执念已碎
    2020-12-15 05:06

    Honestly, I couldn't find any in-built way to do it. So created custom pipe called split.

    working Demo: http://plnkr.co/edit/KX7hfaV2i7CX2VFobM8R?p=preview

    import{Component,provide,Pipe,PipeTransform} from '@angular/core';
    
    @Pipe({name:'split'})
    export class ShiftPosition implements PipeTransform {
      transform(items: any[], value: string): string {
          return items.substr(1)+' ' +items.substr(0,1);
      }
    }
    
    
    @Component({
      selector:"my-app",
    
      template:`
        

    Dashboard

    {{price|currency:'EUR':true|split:price}} ` }) export class AppComponent{ price=10; }

提交回复
热议问题