简体   繁体   中英

How can I get the selected date from an Angular date picker and pass it to $http service parameter

I am calling the AngularJS service $http and I would like to use the date value from an Angular-Material date picker component as a parameter in the below params date value .

$http({
    method : 'GET',
    url : 'theurltobeused',
    params : { pdate : **date value**}
...

Here is my angular-material date picker component

<div flex="20">
  <md-datepicker ng-model="data.myDate" md-placeholder="Enter date" md-min-date="ctrl.minDate" md-max-date="ctrl.maxDate">
  </md-datepicker>
</div>

if i try

... params : {pdate : $scope.data.myDate}...

I get an error TypeError: Cannot read property 'myDate' of undefined

Juse use ctrl.data.mydate

 <md-datepicker ng-model="ctrl.data.mydate" md-placeholder="Enter date" md-min-date="ctrl.minDate" md-max-date="ctrl.maxDate">
 </md-datepicker>

and then

 params : {pdate : this.data.mydate}.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM