0

I have this markup

<!--visible for permanent no-test-->
<md-content
        ng-if="$ctrl.voice.isTest === false && $ctrl.voice.type === 'Permanent'"
        layout="column">
    <md-content layout="row">
        <md-input-container>
            <label>From Date</label>
            <md-datepicker ng-model="$ctrl.voice.coreConditionFromUi.fromDate"
                           datetime="yyyy-MM-dd" md-min-date="$ctrl.today"></md-datepicker>
        </md-input-container>
    </md-content>
</md-content>

with this model:

function Voice() {
    this.isTest = true;
    this.coreConditionFromUi =
    {
        countries: [],
        userFlag : "STAFF",
        fromDate : undefined,
        toDate   : undefined //new Date()
    }
}

When i open the datepicker it shows a date of next month.

I want it to show today's date

I saw this post, but i don't want to set new Date() in the model

as I want to allow null value.

How can i achieve that?

3
  • Is there a reason not to set new Date() in the model? That seems like the easiest way to do it. Commented Apr 4, 2017 at 13:34
  • $filter('date')($scope.Date, 'MM/dd/yyyy'); Commented Apr 4, 2017 at 13:41
  • @Razzildinho i want to allow null when not chosen Commented Apr 4, 2017 at 14:45

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.