Change regional to "en" datepicker with Angularjs

Asked

Viewed 1,358 times

1

I would like to change the Reginal to "en" on my datepicker, I am using Angularjs.

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

var myApp= angular.module('app', []);
myApp.directive('datepicker', function() {


return {  
require: 'ngModel',
link: function(scope, el, attr, ngModel) {
  $(el).datepicker({
    onSelect: function(dateText) {
      scope.$apply(function() {
        var date = Date.parse(dateText) || 0;
        ngModel.$setViewValue(date);
      });
    }
  });
} 

};
});
  • Have any answers solved what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?

1 answer

1

Add the respective locale file to the page header, as an example:

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.6.2/angular.js"></script>
<script src="http://code.angularjs.org/1.6.2/i18n/angular-locale_pt-br.js"></script>
  • In this case, in the directive I created, do I have to put this information in? For example: Return ː require: 'ngModel', link: Function(Scope, el, attr, ngModel) { $(el). datepicker({ locale: "en" onSelect: Function(dateText) { Scope.$apply(Function() { var date = Date.parse(dateText) || 0; ngModel.$setViewValue(date); }); } }); } };&##Xa;}; };;});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.