Skip to content

Commit

Permalink
optional: show placeholder for empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
hutzelknecht committed Oct 6, 2015
1 parent 86a6c5d commit c7dc8b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions source/directives/select-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ module formFor {
disable: '=',
help: '@?',
multiple: '=?',
showPlaceholderForEmptyValues: '=?',
options: '='
};

Expand Down Expand Up @@ -315,9 +316,9 @@ module formFor {
$scope.bindableOptions.push.apply($scope.bindableOptions, $scope.options);

// Once a value has been selected, clear the placeholder prompt.
if ($scope.model.bindable) {
if ($scope.model.bindable && !$scope.showPlaceholderForEmptyValues) {
$scope.emptyOption[$scope.labelAttribute] = '';
} else if ($scope.model.bindable === undefined) {
} else if ($scope.showPlaceholderForEmptyValues && $scope.model.bindable === undefined) {
$scope.emptyOption[$scope.labelAttribute] = $scope.placeholder;
}
};
Expand Down

0 comments on commit c7dc8b5

Please sign in to comment.