栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何以单一形式使用多个Angular UI Bootstrap Datepicker?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何以单一形式使用多个Angular UI Bootstrap Datepicker?

我有一种形式的30个控制器,没问题。如果需要在ng-repeat上使用相同的概念。

 <label>First Date</label>      <div >     <input type="text"  datepicker-popup="{{format}}"  name="dt" ng-model="formData.dt" is-open="datepickers.dt"  datepicker-options="dateOptions" ng-required="true"  close-text="Close" />      <span >        <button  ng-click="open($event,'dt')"> <i ></i></button>      </span>    </div> <label>Second Date</label>      <div >     <input type="text"  datepicker-popup="{{format}}"  name="dtSecond" ng-model="formData.dtSecond"  is-open="datepickers.dtSecond" datepicker-options="dateOptions"  ng-required="true" close-text="Close" />      <span >        <button  ng-click="open($event,'dtSecond')"> <i ></i></button>      </span>    </div>myApp.controller('DatePickrCntrl', function ($scope) {      $scope.datepickers = {        dt: false,        dtSecond: false      }      $scope.today = function() {        $scope.formData.dt = new Date();        // ***** Q1  *****        $scope.formData.dtSecond = new Date();      };      $scope.today();      $scope.showWeeks = true;      $scope.toggleWeeks = function () {        $scope.showWeeks = ! $scope.showWeeks;      };      $scope.clear = function () {        $scope.dt = null;      };      // Disable weekend selection      $scope.disabled = function(date, mode) {        return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );      };      $scope.toggleMin = function() {        $scope.minDate = ( $scope.minDate ) ? null : new Date();      };      $scope.toggleMin();      $scope.open = function($event, which) {        $event.preventDefault();        $event.stopPropagation();        $scope.datepickers[which]= true;      };      $scope.dateOptions = {        'year-format': "'yy'",        'starting-day': 1      };      $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'shortDate'];      $scope.format = $scope.formats[0];}); // ***** Q2 ***** somemodel can be just an array [1,2,3,4,5] <div ng-repeat="o in somemodel"> <label>Date Label</label>      <div >     <input type="text"  datepicker-popup="{{format}}" name="dt{{o}}" ng-model="datepickers.data[o]"  is-open="datepickers.isopen[o]" datepicker-options="datepickers.option"  ng-required="true" close-text="Close" />      <span >        <button  ng-click="open($event,o)"> <i ></i></button>      </span>    </div>  </div>myApp.controller('DatePickrCntrl', function ($scope) {      $scope.datepickers = {        data: {},        options: { 'year-format': "'yy'", 'starting-day': 1        },        isopen: {}      }      $http.get("get/data/for/some/model", function(result) {         $scope.somemodel = result;         for (var i = 0; i < result.length; i++) {$scope.datepickers.isopen[result] = false;$scope.datepickers.data[result] = new Date(); //set default date.         }      });  // fill in rest of the function});


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/636203.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号