One thing it doesn't handle is if the model is set to null. You can see I changed the clear() function to set the selectedCars = [] instead of selectedCars = null. Anyways just submitting this to help jumpstart your fix; I'm sure you'll know a better way to do so.
Might not be the best way to do so but it kinda works. Here's a PLNKR that demonstrates. http://plnkr.co/edit/MjKBW2TpASsMo5xoui0Z?p=preview
One thing it doesn't handle is if the model is set to null. You can see I changed the clear() function to set the selectedCars = [] instead of selectedCars = null. Anyways just submitting this to help jumpstart your fix; I'm sure you'll know a better way to do so.