2016-10-06 1 views
-1

をexeファイルするために、今日でcmpの:Datapickersは、私はこのコードを作成しているjQueryのコード

<div class="option"> 
 
    <label for="date">Date de debut de reservation</label> 
 
    <input type="date" id="datepickerFrom" ui-date="dateOptionsFrom" ng-model="datepickerFrom" class="form-control ng-empty hasDatepicker ng-touched ng-dirty ng-valid-parse ng-invalid ng-invalid-ui-date-validator" name="datepickersFrom" placeholder="dd/mm/yyyy" min="<?php echo $today; ?>" required> 
 
    <script> 
 
     var today = new Date().toISOString().split('T')[0]; 
 
     document.getElementsByName("datepickersFrom")[0].setAttribute('min', today); 
 
    </script> 
 
</div>

が、私は今日の日付で選択した日付を比較したいです。

それが今日の日は、私は以下のコードを実行したい選択された場合であれば:

$("#exptype").append('<option value="fast" selected>Ultra-express 1 heure</option>'); 

を今日の日付が選択されていない場合はそうでない場合、私はこのコードを実行したいと思います:

$("#exptype").append('<option value="stand">Livraison standard 24-48h</option>'); 

どうすればいいですか?

答えて

0

あなたは角を使用していますか?あなたの日付入力にng-model属性が設定されているとします。そのような場合は、角度コントローラーを使用してこれを処理できます(下記の例を参照)。また

、あなたが角度を使用している、そして、あなたが豊かに/より堅牢なUIコントロールのangular date picker controlsを使用して見て可能性が想定...私はjQuerry 2.2.4使用

angular.module('myApp',[]).controller('dateController',function($scope) { 
 
    var today = new Date().toISOString().split('T')[0]; 
 
    $scope.datepickerFrom = today; 
 
    $scope.todaySelected = true; 
 
    //this replaces that line you had: 
 
    //document.getElementsByName("datepickersFrom")[0].setAttribute('min', today); 
 
    $scope.minDate = today; 
 

 
    //when the date changes, store a boolean in our controller scope, to be used in the filter function below 
 
    $scope.dateChanged = function() { 
 
    $scope.todaySelected = ($scope.datepickerFrom == today); 
 
    }; 
 
    //define our options - please adjust for your needs 
 
    $scope.expTypeOptions = [ 
 
    { value: "four hours", text: "4 heure" },   
 
    { value: "fast", text: "Ultra-express 1 heure" }, 
 
    { value: "stand", text: "Livraison standard 24-48h" }, 
 
    ]; 
 
    //this function handles showing the expType options in the select list, 
 
    //based on the selected date 
 
    $scope.filterOptionsByDate = function(expType) { 
 
    if ($scope.todaySelected) { //hide the 'stand' option 
 
     return expType.value != "stand"; 
 
    } 
 
    else { //otherwise show everything except the 'fast' option 
 
     return expType.value != "fast"; 
 
    } 
 
    }; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> 
 
<div class="option" ng-app="myApp" ng-controller="dateController"> 
 
    <label for="date">Date de debut de reservation</label> 
 
    <input type="date" id="datepickerFrom" ui-date="dateOptionsFrom" ng-model="datepickerFrom" class="form-control ng-empty hasDatepicker ng-touched ng-dirty ng-valid-parse ng-invalid ng-invalid-ui-date-validator" min="{{ minDate }}" ng-change="dateChanged()" name="datepickersFrom" placeholder="dd/mm/yyyy" required > 
 
    <div> 
 
     <select ng-model="expType" ng-options="expType.text for expType in expTypeOptions | filter:filterOptionsByDate">    
 
     </select> 
 
</div>

+0

、私は角度jsの3.1.0を追加すると、私は多くのerrosを持っています、それはangularjs 1.5.7 ????? – darkraja

+0

angular.js:36未知のエラー:[$ injector:modulerr] http://errors.angularjs.org/1.2.23/$injector/modulerr?p0=myApp&p1=Error%3A%...gleapis.com%2Fajax%2Flibs %2Fangularjs%2F1.2.23%2Fangular.min.js%3A17%3A415)angular.jsで :angular.jsで36 :3906 でr(angular.js:325) でe(angular.js:3872) )GCで (angular.js:3812)cにおける (angular.js:1444)FC(angular.jsで :1459)Xcの(angular.jsで :1368)angular.jsで :21949 でHTMLDocument.a(angular.js:2573) – darkraja

+0

_bootstrap CSS_バージョン3.1.0を意味しますか?私はブートストラップCSS 3.1.0でAngularのバージョン1.2.xを使用する[このデモページ](http://angular-ui.github.io/bootstrap/versioned-docs/0.12.0/)を見ています - 一度ご覧くださいそのページの例を参照してください。 Angular 2を意味するならば、それに切り替えることができます - 詳細については[angular.io](https://angular.io/)を見てください... –

関連する問題