From 0f1b48aa89bb661dd3f3074ff9cc2df24214ff51 Mon Sep 17 00:00:00 2001 From: Nate Brustein Date: Mon, 7 Dec 2015 12:25:03 -0500 Subject: [PATCH] fix(attrs): make placeholder and title bindable --- dist/angular-selectize.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dist/angular-selectize.js b/dist/angular-selectize.js index a009975..af9cfe0 100755 --- a/dist/angular-selectize.js +++ b/dist/angular-selectize.js @@ -94,6 +94,23 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz scope.$watch('ngDisabled', toggle); }; + // watch for changes to attributes that are copied down to the + // input and keep them in sync. We have set the attr in the watch expression + // rather than in the listener because after an update the selectize library + // may have reverted the placeholder to the un-interpolated value even though + // the value of element.attr(prop) has not changed + var input; + ['placeholder', 'title'].forEach(function(prop){ + scope.$watch(function() { + if (element) { + var val = element.attr(prop); + input = input || element.siblings('.selectize-control').find('input'); + input.attr(prop, val); + } + }); + }); + + element.selectize(settings); element.on('$destroy', function() {