ngx-nic-parser
Version:
A calculator of Date of birth and gender using NIC in SriLanka using Angular
90 lines (73 loc) • 3.55 kB
Markdown
[![NPM version][npm-image]][npm-url]
[](http://opensource.org/licenses/MIT)
[]()
```bash
ng add @ng-bootstrap/ng-bootstrap
```
```bash
npm install ngx-nic-parser --save
```
Add the NgxNicParserModule to the imports of the module.
```js
import {NgxNicParserModule} from "ngx-nic-parser";
@NgModule({
imports: [
NgxNicParserModule
]
})
```
Add the element to your HTML:
```html
<ngx-nic-parser
[]="'title'"
[]="'placeholder'"
(checkDob)="generate($event)"
[]="'id'"
[]="'invalid pattern!'"
[]="'is required!'">
</ngx-nic-parser>
```
And add this to your ts file:
```js
export class AppComponent {
generate($event: any) {
console.log($event);
}
}
```
```js
{
"status": {
"code": 200,
"message": ""
},
"response": {
"day": 9,
"monthName": "JUNE",
"month": 6,
"year": 1999,
"gender": "Male",
"weekDay": "Friday"
}
}
```
| Name | Type | Default | Description |
|-------------------------|---------- | ------------ |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `title` | string | null | Label Name |
| `placeholder` | string| null | placeholder for the input field. |
| `id` | string | null | Id for input field. |
| `patternErrorMessage` | string | null | Error Message when input an incorrect pattern. |
| `requiredMessage` | string | null | Field is required message. |
| Name | Type | Description |
| ----------------------- | ----------------- | ----------- |
| `checkDob` | method | Method to calculate DOB |
[]: https://www.npmjs.com/package/ngx-nic-parser
[]: https://img.shields.io/npm/v/ngx-nic-parser?style=flat-square