What Is Angular PercentPipe?
number_expression | percent[:digitInfo]
Find the description.
number_expression: An angular expression that will give output a number.
percent : A pipe keyword that is used with pipe operator and it converts number into percent.
digitInfo: It defines a percentage format. We have described the use of digitInfo in
{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
Now find some sample examples.
1. Using default format:
minIntegerDigits = 1
minFractionDigits = 0
maxFractionDigits = 3
Now find a number that will be changed into percentage.
Now use Percent Pipe
Find the output.
2. Use format '2.2-5'
minIntegerDigits = 2
minFractionDigits = 2
maxFractionDigits = 5
Now find the number that will be changed into percentage.
Now use Percent Pipe.
Find the output.
We will observe that there is two digits in fraction part. This is because minimum fraction digits required is 2.
Now find the component used in our example.
percentpipe.component.ts
Find the output.
PercentPipe
AngularPercentPipe
is an angular Pipe
API that formats a number as a percentage according to locale rules. It belongs to CommonModule. Find the syntax.number_expression | percent[:digitInfo]
Find the description.
number_expression: An angular expression that will give output a number.
percent : A pipe keyword that is used with pipe operator and it converts number into percent.
digitInfo: It defines a percentage format. We have described the use of digitInfo in
DecimalPipe
section. It is used with following syntax.{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}
Now find some sample examples.
1. Using default format:
minIntegerDigits = 1
minFractionDigits = 0
maxFractionDigits = 3
Now find a number that will be changed into percentage.
2. Use format '2.2-5'
minIntegerDigits = 2
minFractionDigits = 2
maxFractionDigits = 5
Now find the number that will be changed into percentage.
Now find the component used in our example.
percentpipe.component.ts
0 comments:
Post a Comment