1

I have this input

<input type="time" [(ngModel)]="post.time" value="{{selectedTime}}"
                               formControlName="scheduled-time">

The time looks like this:

--:--:--

How can I make the default is the current time?

1

2 Answers 2

3

In constructor set post.time to string of the value. i.e 21:37

Here's demo https://stackblitz.com/edit/angular-vk4kyc

Remember that hours and minutes must have 2 digits

Sign up to request clarification or add additional context in comments.

Comments

2

You can set the value by assigning value (eg. '15:30') to your ngModel property

For more details: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time

Also, I don't understand why you have ngModel, formControlName and value being used at the same time. You need only one of these at any time

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.