Created
January 14, 2015 07:15
-
-
Save ktknest/72df53ae61c071d15b1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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