title: Angular - Set Default Value For Input Type Number In Form Control
body: <p>I am trying to set the input type number's default (initial) value as 1 but is having a difficult time figuring out how to do it. I know that I can set the value with <code>value="1"</code> if there is no <code>formControlName</code>.  I tried <code>inputNum: new FormControl(1, [Validators.required, Validators.pattern('^[1-9]\\d*$')])</code> </p>
  
  <p>and </p>
  
  <p><code>inputNum: new FormControl([1, Validators.required, Validators.pattern('^[1-9]\\d*$')])</code> without success.</p>
  
  <p>The input should have the initial value of 1 but I should be able to set it as 1 to whatever positive whole number.</p>
  
  <pre><code> &lt;input formControlName="inputNum" class="form-control" [ngClass]="{'is-invalid':inputNumForm.touched &amp;&amp; inputNumForm.errors}" type="number"&gt;
      &lt;div class="invalid-feedback" *ngIf="inputNumForm.touched &amp;&amp; inputNumForm.errors"&gt;
         &lt;label *ngIf="inputNumForm.errors.required"&gt;Numbers Only&lt;/label&gt;
      &lt;/div&gt;
  </code></pre>
  
  <pre><code>  public form = new FormGroup({
      inputNum: new FormControl('', [Validators.required, Validators.pattern('^[1-9]\\d*$')]),
    });
  
    get inputNumForm(): FormControl {
      return this.form.controls['inputNum'] as FormControl;
    }
  
  </code></pre>