Áp dụng AngularJS trong iif

Áp dụng AngularJS trong iif

1. Combo chọn ngày trong angular

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular-sanitize.js"></script>
<div ng-app="myApp" ng-controller="myCtrl" id="divID">
<form>
<div class="form-row">


<div class="form-group col-6 col-md-4 col-lg-8" >
         <div class="input-group">
             <div class="input-group-prepend w_title" >
                  <span class="input-group-text w_text" ><i class="far fa-calendar-alt"></i> Ngày:</span>
             </div>
             <select ng-model="DatTruoc_Ngay" class='form-control' ng-options="x for x in arrNgay"></select>
         </div>
</div>
<div class="form-group col-6 col-md-4 col-lg-4"  >
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" ng-click="ThayDoiNgay(-1)" type="button">-</button>
    <button class="btn btn-outline-success"  ng-click="ThayDoiNgay(1)" type="button">+</button>
  </div>
</div>
<div class="form-group col-6 col-md-4 col-lg-4" >
         <div class="input-group">
              <div class="input-group-prepend w_title" >
                  <span class="input-group-text w_text" >Tháng:</span>
             </div>
              <select ng-model="DatTruoc_Thang" ng-change="ThayDoiNapNgay()" class='form-control' ng-options="x for x in arrThang"></select>
         </div>
</div>
<div class="form-group col-6 col-md-4 col-lg-4"  >
         <div class="input-group">
             <div class="input-group-prepend w_title" >
                  <span class="input-group-text w_text" >năm:</span>
             </div>
             <select ng-model="DatTruoc_Nam" ng-change="ThayDoiNapNgay()"  class='form-control' ng-options="x for x in arrNam"></select>
         </div>
</div>
<div class="form-group col-6 col-md-6 col-lg-6"  >
         <div class="input-group">
             <div class="input-group-prepend w_title" >
                  <span class="input-group-text w_text" ><i class="far fa-clock"></i> Giờ:</span>
             </div>
             <select ng-model="DatTruoc_Gio" class='form-control' ng-options="x for x in arrGio"></select>
         </div>
</div>
<div class="form-group col-6 col-md-6 col-lg-6 " >
         <div class="input-group">
             <div class="input-group-prepend w_title" >
                  <span class="input-group-text w_text" ><i class="fas fa-tag mr-1"></i> phút:</span>
             </div>
             <select ng-model="DatTruoc_Phut" class='form-control' ng-options="x for x in arrPhut"></select>
         </div>
</div>
</div>
</form>
 <button type="button" class="btn btn-danger" ng-click="Get_Date()"><i class="fas fa-plus"></i> Đồng ý</button>
 <script>
 var app = angular.module("myApp",  ['ngSanitize']);
app.controller('myCtrl', function($scope, $http,$interval){
//***
 $scope.KhoiTao_DateTime = function () {

    $scope.arrThang = [1, 2, 3,4,5,6,7,8,9,10,11,12];
         $scope.arrNam=[]; $scope.arrNgay=[];$scope.arrGio=[]; $scope.arrPhut=[];
         ngayhienhanh=new Date();nam= ngayhienhanh.getFullYear();
         for(i=nam ;i<nam+2;i++){$scope.arrNam.push(i);}
         for(i=0 ;i<23;i++){$scope.arrGio.push(i);}
         for(i=0 ;i<59;i++){$scope.arrPhut.push(i);}
         $scope.DatTruoc_Thang = ngayhienhanh.getMonth()+1;
         $scope.DatTruoc_Nam = ngayhienhanh.getFullYear();
         $scope.DatTruoc_Gio =  12;//ngayhienhanh.getHours();
         $scope.DatTruoc_Phut =0 ;// ngayhienhanh.getMinutes();
         $scope.DatTruoc_Ngay = ngayhienhanh.getDate();
    }//KhoiTao_DateTime
    $scope.KhoiTao_DateTime();
    $scope.loadNgay = function (thang,nam) {    
        tongngay= new Date(nam, thang, 0).getDate();
        $scope.arrNgay=[];
         for(i=1 ;i<=tongngay;i++)
        {
         $scope.arrNgay.push(i);
        }
    }
     $scope.loadNgay (  $scope.DatTruoc_Thang,  $scope.DatTruoc_Nam);
     $scope.ThayDoiNapNgay = function () {    
        $scope.loadNgay (  $scope.DatTruoc_Thang,  $scope.DatTruoc_Nam);
        }
      $scope.ThayDoiNgay = function (st) {       
        var ngay_hh = new Date($scope.DatTruoc_Nam,$scope.DatTruoc_Thang-1,$scope.DatTruoc_Ngay)
        ngay_hh.setDate(ngay_hh.getDate() + st);
          $scope.DatTruoc_Ngay=ngay_hh.getDate();
          $scope.DatTruoc_Thang=ngay_hh.getMonth()+1;
          $scope.DatTruoc_Nam=ngay_hh.getFullYear();
       // alert(ngay_hh);
      }
      // get date
       $scope.Get_Date = function () {
            $scope.ngaykichhoat =convertStrToObjDate_num($scope.DatTruoc_Ngay,$scope.DatTruoc_Thang,$scope.DatTruoc_Nam,$scope.DatTruoc_Gio,$scope.DatTruoc_Phut );
            $scope.ngaykichhoat= convertDateObjToStr_saveDB( $scope.ngaykichhoat);
            alert($scope.ngaykichhoat);
          
     };  //Get_Date
//***
});
 
 </script>
 
</div>

Bài viết liên quan:

Áp dụng AngularJS trong iif