Angular JS将区域语言添加到jQuery ui-datepicker指令中

时间:2017-02-17 11:58:47

标签: javascript angularjs jquery-ui jquery-ui-datepicker

请您帮我将$.datepicker.setDefaults( $.datepicker.regional[ "fr" ] );添加到角度ui-datepicker指令中 这是一个我正在使用的jsfiddle

1 个答案:

答案 0 :(得分:0)

var datePicker = angular.module('app', []);

datePicker.directive('jqdatepicker', function() {
  return {
    restrict: 'A',
    require: 'ngModel',
    link: function(scope, element, attrs, ngModelCtrl) {
      element.datepicker({
        dateFormat: 'DD, d  MM, yy',
        onSelect: function(date) {
          scope.date = date;
          scope.$apply();
        }
      });
    }
  };
});
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script type="text/javascript" src="//jqueryui.com/resources/demos/datepicker/i18n/datepicker-fr.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<link rel="stylesheet" type="text/css" href="//codeorigin.jquery.com/ui/1.10.3/themes/redmond/jquery-ui.css">

<body ng-app="app">
  <input type="text" ng-model="date" jqdatepicker />
  <br/> {{ date }}



</body>

在脚本中添加<script type="text/javascript" src="//jqueryui.com/resources/demos/datepicker/i18n/datepicker-fr.js"></script>