I have been utilizing ng-options to create a dropdown menu for values that may change infrequently. In a larger example, I have approximately 50 options in the array, and I noticed a decrease in performance each time I made a selection. It seems that ng-options is being reevaluated every time I make a change. Is there a way to prevent this from happening? You can view a simplified example here:
Specifically, this function:
scope.formatItem = function (item) {
console.log('formatting item.');
return item.someProp1 + '/' + item.someProp2;
};
is called to format each item for display in the dropdown, but I only want it to run once per item on the initial list.
The Chrome console displays a total of 9 log statements before any selection is made, followed by 3 after each subsequent change. My initial thought is to use compile
, but I would appreciate some guidance.