From 31fbfc0c52a300657da329b5ac9befb60e028a69 Mon Sep 17 00:00:00 2001 From: Michael Washburn Date: Thu, 13 Oct 2016 20:41:05 -0400 Subject: [PATCH] Add ng-attr-placeholder Add ng-attr attribute to directive --- inputDropdown.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/inputDropdown.js b/inputDropdown.js index eb64b8f..f385c89 100644 --- a/inputDropdown.js +++ b/inputDropdown.js @@ -4,6 +4,7 @@ angular.module('inputDropdown', []).directive('inputDropdown', [function() { '' + '
  • ' + '{{item.readableName}}' + @@ -33,6 +34,7 @@ angular.module('inputDropdown', []).directive('inputDropdown', [function() { inputRequired: '=', inputName: '@', inputPlaceholder: '@', + inputNgAttrPlaceholder: '@', filterListMethod: '&', itemSelectedMethod: '&' }, @@ -75,7 +77,6 @@ angular.module('inputDropdown', []).directive('inputDropdown', [function() { scope.$watch('selectedItem', function(newValue, oldValue) { inputScope.updateInputValidity(); - if (!angular.equals(newValue, oldValue)) { if (newValue) { // Update value in input field to match readableName of selected item if (typeof newValue === 'string') { @@ -85,11 +86,6 @@ angular.module('inputDropdown', []).directive('inputDropdown', [function() { scope.inputValue = newValue.readableName; } } - else { - // Uncomment to clear input field when editing it after making a selection - // scope.inputValue = ''; - } - } }); scope.setInputActive = function() { @@ -112,6 +108,9 @@ angular.module('inputDropdown', []).directive('inputDropdown', [function() { } else if (scope.allowCustomInput) { inputScope.updateInputValidity(); + if (scope.itemSelectedMethod) { + scope.itemSelectedMethod({item: scope.inputValue}); + } } if (scope.filterListMethod) {