2017-04-24 1 views
0

私はrestapiにcurentの日付を送ろうとしているので、私はそれを扱うことができます。私は割り当て、このよう$http.postメソッドの上にパラメータを渡しています:

(function() { 
     var app; 

     app = angular.module('vinclucms.sales'); 

     app.controller('FilterContactsListCtrl', [ 
     '$scope', '$http', function($scope, $http) { 
      var nextContactListUpdateFailed, nextContactListUpdateSuccess; 
      $scope.selectDate = null; 
      $scope.doAction = function() { 
      var data; 
      data = { 
       date: $scope.selectDate 
      }; 
      return $http.post("/sales/lead_contact/", data).then(nextContactListUpdateSuccess, nextContactListUpdateFailed); 
      }; 
      nextContactListUpdateSuccess = function() { 
      return ClientNotifications.showNotification("Success", "Contact Leads list page was updated", "success"); 
      }; 
      return nextContactListUpdateFailed = function() { 
      return ClientNotifications.showNotification("Alert", "Failed to update contact leads list page", "alert"); 
      }; 
     } 
     ]); 

    }).call(this); 

現在nullに設定されていると私は私が私の見解をデバッグするとき、それはNoneを返します残りの部分でそれに問題を抱えているが、問題は私がどのようにできています現在の日付を$http.postの方法で渡しますか?

私はあなたが日付変換を行う必要があり、あなたは以下のようなとして試すことができ、現在の日付の場合は

var data; 
data = { 
    date: $filter('date')(new Date($scope.selectDate), 'MM/dd/yyyy', 'US') 
}; 

も日付

<div class="flex-grid" 
      ng-controller="FilterContactsListCtrl"> 
     <div class="row"> 
      <div class="cell size-p20 padding10"> 
       <label>Select Date: *</label> 
       <div class="full-size"> 
        <div class="input-control text" data-other-days="true" 
         data-week-start="1" 
         data-role="datepicker" date-format="mmmm d, yyyy"> 
         <input type="text" ng-model="selectDate" ng-change="doAction()"/> 
         <button class="button"> 
          <span class="mif-calendar"></span></button> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
+0

$フィルターを注入してください? '/ sales/lead_contact /'エンドポイントメソッドでは?そのメソッドのコードも提供できますか? – eminlala

+0

他にも 'djangorestframework'ビューの中に他のことが起こっているので、私は混乱したくない、私は純粋な角度コードのこの部分に興味があった、私はフィルタを追加しようとするだろうが、別の提案があれば、それを聞くために開いたm @eminlala – PetarP

答えて

1

を選択するために使用している日付時刻ピッカーフィールド:

var data; 
data = { 
    date: $filter('date')(new Date(), 'MM/dd/yyyy', 'US') 
}; 

注:コントローラーそれはnull`なので `に設定されている

関連する問題