If you want some content as text in input type number then you can use a placeholder too, besides that.
This can also be done using Angular's Form Validations
Using ngModel in a form gives you more than just two-way data binding. It also tells you if the user touched the control, if the value changed, or if the value became invalid.
The NgModel directive doesn't just track state; it updates the control with special Angular CSS classes that reflect the state. You can leverage those class names to change the appearance of the control
You can make use of
- ng-valid or ng-invalid to get true or false on the type of validity
ng-dirty and ng-pristine to know if the user has changed the default value
ng-touched or ng-untouched to know if the the user has reacted or touched the input field
Example snippet
<input type="text" class="form-control" id="name" required [(ngModel)]="model.name" name="name" #name="ngModel">
<div [hidden]="name.invalid" class="alert alert-danger">
Name is required
</div>
<div [hidden]="name.pristine" class="alert alert-danger">
No value entered yet
</div>
For more reference on Angular Validation
Or you could call an event as
<input type="number" class="form-control" [(ngModel)]="home" name="home" required min="0" step="1" (focusout)="callMethod($event)"> <=== here
<div *ngIf="showErrorOne==1"> Regex Error </div>
<div *ngIf="showErrorTwo==1"> Type Error </div>
Then in your .ts file
callMethod(e)
{
var checkerVar = e.target.value
if(checkerVar.match(/(Your regex part)/)==false)
{
then.showErrorOne=1;
}
else if(typeof(checkerVar)==string)
{
then.showErrorTwo=1;
}
}