1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
...
npm i sh-ordinal-numbers
import { OrdinalNumbersModule } from 'sh-ordinal-numbers';
@NgModule({
imports: [OrdinalNumbersModule],
})
export class AppModule { }
<p>{{ 16 | ordinal}}</p> // Output: 16th
import { OrdinalNumbersModule, OrdinalPipe } from 'sh-ordinal-numbers';
@NgModule({
imports: [OrdinalNumbersModule],
providers: [OrdinalPipe]
})
export class AppModule { }
import { OrdinalPipe } from 'sh-ordinal-numbers';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
providers: [OrdinalPipe]
})
import { OrdinalPipe } from 'sh-ordinal-numbers';
ordinal: string = '';
constructor(private ordinalPipe: OrdinalPipe) {
this.ordinal = this.ordinalPipe.transform(16); // Output: 16th
}
MIT