We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当把一个变量如日期显示在ng-model上时,有时需要对显示的内容进行格式化,但是ng-model上是不支持| filter这样的,因此需要单独写directive来实现。
| filter
<input type="text" ng-model="start_date" date-format disabled="disabled">
angular.module('dateRange',[]).directive('dateFormat', ['$filter',function($filter) { var dateFilter = $filter('date'); return { require: 'ngModel', link: function(scope, elm, attrs, ctrl) { function formatter(value) { return dateFilter(value, 'yyyy-MM-dd'); //format } function parser() { return ctrl.$modelValue; } ctrl.$formatters.push(formatter); ctrl.$parsers.unshift(parser); } }; }]);
The text was updated successfully, but these errors were encountered:
natee
No branches or pull requests
当把一个变量如日期显示在ng-model上时,有时需要对显示的内容进行格式化,但是ng-model上是不支持
| filter
这样的,因此需要单独写directive来实现。The text was updated successfully, but these errors were encountered: