0

I want to make my input a default value as a small validate for user. But I can't seem to make it work since ngModel make it goes blank all the time.

<p class="mgRight">Second: <input type="number" min="1" [(ngModel)]="secondOnce" [(ng-init)]="secondOnce='1'" /></p>
  • 1
    define `model` in `component` and pass default value. eg: `@Input() secondOnce : number = 1 ` here is full documentations https://angular.io/api/core/Input – PHP Ninja Feb 11 '20 at 05:41
  • Thank you, it's work. Is there a way for me to prevent people from typing into it? Like you can edit it by cliking the arrow up-down but can't press anything. –  Feb 11 '20 at 05:54
  • here is solution https://stackoverflow.com/questions/50230964/how-to-disable-keyboard-keys-using-angular-2-but-the-keys-should-be-work-on-h – PHP Ninja Feb 11 '20 at 06:04
  • Why are you using the hangfire tag? – tom redfern Feb 11 '20 at 09:03
  • 1
    @tomredfern oh I'm sorry. Will fix it right now. –  Feb 11 '20 at 09:51
  • Thank you. Also if you have a solution to the question then please post it as an answer. That way others can benefit. – tom redfern Feb 11 '20 at 11:58

0 Answers0