Skip to content

Commit

Permalink
Performance: Adjust $watch statement so it does not run every $digest
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Schuman committed Aug 7, 2014
1 parent 48ee70e commit 15d5465
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/nya-bootstrap-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ angular.module('nya.bootstrap.select',[])
angular.forEach(BS_ATTR, function(attr) {
selectorOptions[attr] = attrs[attr];
});

return selectorOptions;
};

/**
Expand Down Expand Up @@ -119,7 +121,8 @@ angular.module('nya.bootstrap.select',[])
// This is slow, but not as slow as calling optionDOMWatch every $digest
return {
ngModel: ngCtrl.$viewValue,
options: makeOptionArray( $(element).find('option') )
options: makeOptionArray( $(element).find('option') ),
selectors: updateSelectorOptions()
};
// If any of the above properties change, call optionDOMWatch.
}, optionDOMWatch, true);
Expand Down

0 comments on commit 15d5465

Please sign in to comment.