title: How to add "-" automatically for mobile number input field while keyup into input field in angular 6
body: <p>I have a input type text, I want to basically make it for mobile number and add "-" automatically while typing into textbox, for example 999-999-9999, I already tried but its not working. Here is the code below</p>
  
  <h2>app.component.html</h2>
  
  <pre><code>&lt;input (keydown)=onKeydownEvent($event) type="text" maxlength="9" placeholder="mobile number"/&gt;
  </code></pre>
  
  <h2>app.component.ts</h2>
  
  <pre><code>import { Component } from "@angular/core";
  
  @Component({
    selector: "app-root",
    templateUrl: "./app.component.html",
    styleUrls: ["./app.component.css"]
  })
  export class AppComponent {
    show: any;
    name: string = '2019-01-01T23-00-11';
    //name: string = '2019-01-01';
    ngOnInit() {
  
    }
  
    onKeydownEvent($event) {
      $(event).val($(event).val().replace(/(\d{3})\-?(\d{3})\-?(\d{4})/, '$1-$2-$3'))
    }
  }
  </code></pre>