From 21712f60128bd701622eb60dce598b8915012ac3 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Tue, 7 Apr 2015 18:05:10 -0600 Subject: [PATCH] Don't watch other keys on options. Doing so can sometimes result in an infinite digest loop. This way, only value and label keys are taken into account. --- dist/selectize.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dist/selectize.js b/dist/selectize.js index 22bbd59..d7c923d 100755 --- a/dist/selectize.js +++ b/dist/selectize.js @@ -104,7 +104,16 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz angularCallback(selectize); } - scope.$watch('options', function(){ + scope.$watch(function(){ + return scope.options.map(function(r){ + angular.forEach(r, function(val, key) { + if ([config.valueField, config.labelField].indexOf(key) == -1) { + delete r[key]; + } + }); + return r; + }); + }, function(val){ selectize.clearOptions(); selectize.addOption(scope.options) selectize.setValue(scope.ngModel)