Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

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 postpost, but i don't want to set new Date() in the model

as I want to allow null value.

How can i achieve that?

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?

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?

removed horizontal scroll from HTML code
Source Link
Michael Doye
  • 8.2k
  • 5
  • 43
  • 57
                                    <!--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>
                                    <!--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>
<!--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>
Source Link
Elad Benda2
  • 15.8k
  • 30
  • 89
  • 165

open angular material datepicker on today but can still be null

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?