Skip to content
New issue

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

Placeholder show problem #97

Open
kurkin-d opened this issue Jul 5, 2016 · 2 comments
Open

Placeholder show problem #97

kurkin-d opened this issue Jul 5, 2016 · 2 comments

Comments

@kurkin-d
Copy link

kurkin-d commented Jul 5, 2016

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.

@adlh
Copy link

adlh commented Jul 19, 2016

+1

@JirkaChadima
Copy link

JirkaChadima commented Jul 29, 2016

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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants