Service Portal date field

stevethomas
Giga Contributor

Hi all,

I have a widget on a Service Portal page that uses fill out.  One of the fields is a date field.  I want the field to auto populate with "todays" date.  Below is the code that I have, but not sure how to get the date field to auto populate.

<label for="dateRequested">Date of Request:</label>
<input type="date" id="dateRequested" ng-required="data.dateRequested" ng-model="data.dateRequested">

1 ACCEPTED SOLUTION

asifnoor
Kilo Patron

Hi,

Why don't you use sp_date_picker directive.

<sp-date-picker ng-model="your.model.value" sn-change="your_function()"></sp-date-picker>

View solution in original post

8 REPLIES 8

Shantharao
Kilo Sage

Hi,

Can you try with this logic

<input type="date" id="dateRequested" ng-required="data.dateRequested" ng-model="new Date()">

 

if my response helps you please hit or mark as correct answer

Shantharao,

I tried the code but it did not work.

@Shantharao That is not the right way to use ngModel.  ngModel is supposed to bind the input to a property on the scope.  You can't just put in arbitrary javascript declarations like that.

https://docs.angularjs.org/api/ng/directive/ngModel

asifnoor
Kilo Patron

Hi,

Why don't you use sp_date_picker directive.

<sp-date-picker ng-model="your.model.value" sn-change="your_function()"></sp-date-picker>