Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hakimesheikhalishahi/sh-ordinal-numbers
angular ordinal number pipe
https://github.com/hakimesheikhalishahi/sh-ordinal-numbers
angular format library number number-format ordinal ordinal-numbers pipe
Last synced: about 1 month ago
JSON representation
angular ordinal number pipe
- Host: GitHub
- URL: https://github.com/hakimesheikhalishahi/sh-ordinal-numbers
- Owner: HakimeSheikhalishahi
- License: mit
- Created: 2022-03-28T12:06:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-18T08:41:43.000Z (almost 3 years ago)
- Last Synced: 2024-12-03T10:47:09.984Z (about 2 months ago)
- Topics: angular, format, library, number, number-format, ordinal, ordinal-numbers, pipe
- Language: TypeScript
- Homepage:
- Size: 138 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ordinal numbers pipe
#### You can add an ordinal suffix to number in Angular.
```
1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
...
```
## Setup### Use npm to install the package
```
npm i sh-ordinal-numbers
```
### Add dependencies to your module:
```typescript
import { OrdinalNumbersModule } from 'sh-ordinal-numbers';@NgModule({
imports: [OrdinalNumbersModule],
})
export class AppModule { }
```
### Now you are able to use imported pipes, for example:
#### In template:
```html{{ 16 | ordinal}}
// Output: 16th
```
#### In component:
##### 1- Provide OrdinalPipe in module
```typescript
import { OrdinalNumbersModule, OrdinalPipe } from 'sh-ordinal-numbers';@NgModule({
imports: [OrdinalNumbersModule],
providers: [OrdinalPipe]
})
export class AppModule { }
```
##### or
```typescript
import { OrdinalPipe } from 'sh-ordinal-numbers';@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [OrdinalPipe]})
```
##### 2-Use in component
```typescript
import { OrdinalPipe } from 'sh-ordinal-numbers';
ordinal: string = '';
constructor(private ordinalPipe: OrdinalPipe) {
this.ordinal = this.ordinalPipe.transform(16); // Output: 16th
}
```
## LicenseMIT