Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Issue #154 Support for interpolated placeholder #177

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/mdpDatePicker/mdpDatePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,14 @@ module.directive("mdpDatePicker", ["$mdpDatePicker", "$timeout", function($mdpDa
transclude: true,
template: function(element, attrs) {
var noFloat = angular.isDefined(attrs.mdpNoFloat),
placeholder = angular.isDefined(attrs.mdpPlaceholder) ? attrs.mdpPlaceholder : "",
openOnClick = angular.isDefined(attrs.mdpOpenOnClick) ? true : false;

return '<div layout layout-align="start start">' +
'<md-button' + (angular.isDefined(attrs.mdpDisabled) ? ' ng-disabled="disabled"' : '') + ' class="md-icon-button" ng-click="showPicker($event)">' +
'<md-icon md-svg-icon="mdp-event"></md-icon>' +
'</md-button>' +
'<md-input-container' + (noFloat ? ' md-no-float' : '') + ' md-is-error="isError()">' +
'<input type="{{ ::type }}"' + (angular.isDefined(attrs.mdpDisabled) ? ' ng-disabled="disabled"' : '') + ' aria-label="' + placeholder + '" placeholder="' + placeholder + '"' + (openOnClick ? ' ng-click="showPicker($event)" ' : '') + ' />' +
'<input type="{{ ::type }}"' + (angular.isDefined(attrs.mdpDisabled) ? ' ng-disabled="disabled"' : '') + ' aria-label="{{placeholder}}" placeholder="{{placeholder}}"' + (openOnClick ? ' ng-click="showPicker($event)" ' : '') + ' />' +
'</md-input-container>' +
'</div>';
},
Expand All @@ -344,7 +343,7 @@ module.directive("mdpDatePicker", ["$mdpDatePicker", "$timeout", function($mdpDa
"maxDate": "=mdpMaxDate",
"dateFilter": "=mdpDateFilter",
"dateFormat": "@mdpFormat",
"placeholder": "@mdpPlaceholder",
"placeholder": "=?mdpPlaceholder",
"noFloat": "=mdpNoFloat",
"openOnClick": "=mdpOpenOnClick",
"disabled": "=?mdpDisabled"
Expand Down Expand Up @@ -398,7 +397,8 @@ module.directive("mdpDatePicker", ["$mdpDatePicker", "$timeout", function($mdpDa
};

ngModel.$validators.required = function(modelValue, viewValue) {
return angular.isUndefined(attrs.required) || !ngModel.$isEmpty(modelValue) || !ngModel.$isEmpty(viewValue);
var isRequired = angular.isDefined(attrs.required) ? attrs.required === true : false;
return !isRequired || !ngModel.$isEmpty(modelValue) || !ngModel.$isEmpty(viewValue);
};

ngModel.$parsers.unshift(function(value) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/mdpTimePicker/mdpTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ module.directive("mdpTimePicker", ["$mdpTimePicker", "$timeout", function($mdpTi
};

ngModel.$validators.required = function(modelValue, viewValue) {
return angular.isUndefined(attrs.required) || !ngModel.$isEmpty(modelValue) || !ngModel.$isEmpty(viewValue);
var isRequired = angular.isDefined(attrs.required) ? attrs.required === true : false;
return !isRequired || !ngModel.$isEmpty(modelValue) || !ngModel.$isEmpty(viewValue);
};

ngModel.$parsers.unshift(function(value) {
Expand Down