Skip to content

Instantly share code, notes, and snippets.

@ktknest
Created January 14, 2015 07:15
Show Gist options
  • Save ktknest/72df53ae61c071d15b1b to your computer and use it in GitHub Desktop.
Save ktknest/72df53ae61c071d15b1b to your computer and use it in GitHub Desktop.
'use strict';
angular.module('myApp')
/**
* @ngdoc directive
* @name myApp:datepickerHotfix
* @restrict A
* @scope false
*
* @description
* ui.bootstrap : datepickerの暫定バグ対策
* AngularJSが1.3以上の場合、ngModelの$viewValueがDateでなくStringで格納されるためちょいと操作します
*
* 以下がCloseされれば不要になるはず。
* SEE: https://github.com/angular-ui/bootstrap/issues/3025
* https://github.com/angular-ui/bootstrap/pull/2943
**/
.directive('datepickerHotfix', function() {
var _directive = {
restrict : 'A',
require : 'ngModel',
link : _link
};
function _link(scope, element, attrs, ngModelController) {
ngModelController.$formatters.unshift(function(value) {
return new Date(value);
});
}
return _directive;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment