DEV Community


Posted on


Answer: How do I calculate age from birth date in Angular using TypeScript

<div class="row"&gt
    <div class="input-field col m2">
        <input type="date" [(ngModel)]="birthdate" id="txtdate">
    <div class="input-field col m4">
        <input type="number" [(ngModel)]="age" id="age">
    <button (click)="CalculateAge()">Calculate Age</button>

And in your component

 import { Component, OnInit } from '@angular/core';
@Component( {
 selector: 'stud',
 templateUrl: './student.component.html'
 export class StudentComponent implements OnInit
    public birthdate:

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.