Package Exports
- ni-datetime-pipe
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ni-datetime-pipe) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
NiDatetimePipe
Angular Pipe for NiDatetime
Installation
npm i ni-datetime-pipeimport { NiDatetimePipeModule } from 'ni-datetime-pipe'; // <= import
@NgModule({
declarations: [
AppComponent
],
imports: [
NiDatetimePipeModule, // <= register
],
providers: [
NiDatetimePipeService // <= add provider
],
bootstrap: [AppComponent]
})
export class AppModule { }Example
- Your component class:
import { Locales } from 'ni-datetime';
import { NiDatetimePipeService } from 'ni-datetime-pipe';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.less']
})
export class AppComponent implements OnInit {
date = new Date();
constructor(private pipeService: NiDatetimePipeService) {
// specify default pipe locale
// or change it when ever you want
this.pipeService.locale = Locales.fa_AF;
}
}- Your component html template:
{{ date | ni_date:"WWWW DD MMMM, YYYY HH:mm:ss A" }}
<!-- دوشنبه 30 جدی, 1398 16:43:21 بعد از ظهر -->
{{ date | ni_date:"WWWW DD MMMM, YYYY HH:mm:ss A":"en_US" }}
<!-- Monday 20 January, 2020 16:43:37 PM -->
{{ date | ni_date:"WWWW DD MMMM, YYYY HH:mm:ss A":YOUR_CUSTOM_NiDatetimeLocale_OBJECT }}
<!-- ... -->Formats
Check NiDatetime for available formats.