change
%select{'ng-model' => 'device', 'ng-options' => 'device.serial_number for device in devices | filter:search'}
to
%select{'ng-model' => 'device', 'ng-options' => 'device.serial_number for device in filtered_devices=(devices | filter:search)'}
and you will have filter_devices in your area to do what you want in particular, you can view it and install the selected device when it changes
$scope.$watch('filtered_devices', function(value){ if (filtered_devices) { $scope.device = filtered_devices[0]; } }, true);
therefore you do not need to filter again ...
UPDATE:
After working with the model, I suggested that I found it probably a bad idea to have a filter expression as the source for ng-options. I guess the reason is that every time a filter is evaluated, it returns a new collection, and therefore the diget loop concludes that it is dirty and needs to be rewritten or something else.
Now I use a different template in which I have a filtered_items collection in my $scope , and I update it with "ng-change" in the filter input. therefore the filtered_items to which ng-options are bound does not change if it really needs to be changed ...
source share