oi.select icon indicating copy to clipboard operation
oi.select copied to clipboard

Placeholder show problem

Open kurkin-d opened this issue 8 years ago • 2 comments

If I write something like this placeholder="{{variable_from_scope}}" placeholder doesn't display. Bug can be repeted in this example http://embed.plnkr.co/LTj8vm5NgYeOKpv22MDL/ If you add variable to controller and try to show the value in placeholder you will see empty field.

kurkin-d avatar Jul 05 '16 14:07 kurkin-d

+1

adlh avatar Jul 19 '16 09:07 adlh

It's because the expression is interpolated with an internal scope which typically does not have the required data. Quick patch follows, but the proper solution would probably be to use the parent scope to interpolate these fields.

And another note: the placeholder gets interpolated just once with this solution, so it does not change dynamically.

--- a/src/directives.js
+++ b/src/directives.js
@@ -54,8 +54,8 @@ angular.module('oi.select')
             return function(scope, element, attrs, ctrl) {
                 var inputElement        = element.find('input'),
                     listElement         = angular.element(element[0].querySelector('.select-dropdown')),
-                    placeholder         = placeholderFn(scope),
-                    multiplePlaceholder = multiplePlaceholderFn(scope),
+                    placeholder         = placeholderFn(scope) || attrs.placeholder || '',
+                    multiplePlaceholder = multiplePlaceholderFn(scope) || attrs.multiplePlaceholder || '',
                     elementOptions      = optionsFn(scope.$parent) || {},
                     options             = angular.extend({cleanModel: elementOptions.newItem === 'prompt'}, oiSelect.options, elementOptions),
                     editItem            = options.editItem,

JirkaChadima avatar Jul 29 '16 08:07 JirkaChadima