The rich Angular pipes mall. This project uses the dataset of countries from countries-data
This project used by ng2-countries.
The project generated with angular-cli.
You can see how fun it is to use this npm in the Demo Application.
- Demo app
- Installation
- Countries Pipes
- Country Anthem - a2ToAnthem
- Country name - a2ToCountry
- Official name
- Native name - Default
- Native name - Specific language
- Country Capital - a2ToCapital
- Country Continent - a2ToContinent
- Country Area - a2ToArea
- Regular number
- With Comma style pipe
- Country Population - a2ToPopulation
- Regular number
- With Comma style pipe
- Country Wiki Link - a2ToWikiLink
- Country alpha 3 (iso_3166_1_alpha3) to alpha 2 - a3ToA2
- Ganeral Pipes
- Comma Style - commaStyle
- Bytes to Mega-bytes - bytesToMBs
- Regular use
- With Comma style pipe (1)
- With Comma style pipe (2)
- How to use
- Development server
- Build
- Deploying to Github Pages
npm install ng2-pipe
The countries pipes work with iso_3166_1_alpha2 (a2) countries codes.
The examples written for Israel (IL)
IL | a2ToAnthem
Result: https://commons.wikimedia.org/wiki/File%3AHatikvah instrumental.ogg?embedplayer=yes
IL | a2ToCountry
Result: Israel
IL | a2ToCountry: [ 'official' ]
Result: State of Israel
IL | a2ToCountry: [ 'native' ]
Result: ישראל
IL | a2ToCountry: [ 'native', 'ara' ]
Result: إسرائيل
IL | a2ToCapital
Result: Jerusalem
IL | a2ToContinent
Result: Asia
IL | a2ToArea
Result: 20770
IL | a2ToArea | commaStyle
Result: 20,770
IL | a2ToPopulation
Result: 8597260
IL | a2ToPopulation | commaStyle
Result: 8,597,260
IL | a2ToWikiLink
Result: https://wikipedia.org/wiki/Israel
ISR | a3ToA2
Result: IL
123456789 | commaStyle
Result: 123,456,789
5389564 | bytesToMBs
Result: 5.14
5389564 | bytesToMBs | commaStyle
Result: 5.14
1024000000000 | bytesToMBs | commaStyle
Result: 976,562.50
import { NgModule } from '@angular/core';
import { CountriesPipesModule, GeneralPipesModule } from 'ng2-pipe';
@NgModule({
imports: [
CountriesPipesModule,
GeneralPipesModule
]
})
export class SharedModule { }
Specific country name: {{ IL | a2ToCountry }}
Country name by parameter: {{ alpha2 | a2ToCountry }}
Country anthem: <a [href]='alpha2 | a2ToWikiLink'></a>
Specific country population: {{ IL | a2ToPopulation | commaStyle }}
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive/pipe/service/class
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the -prod
flag for a production build.
Run ng github-pages:deploy
to deploy to Github Pages.