To add to the answer:
The Qur'anic discussion of angels emphasizes that they are obedient to the command of Allah and "do what they are told". (16:50)
They are also directly aware of the existence of Allah in a way that is more veiled for most humans, and don't experience the animal desires that humans do (which lead to things like greed, jealousy, etc), so they would have no reason to disobey Allah especially in something big like this.
According to some Shi'i narrations, both the Prophet (S) and Imam Ali (A) instructed some of the angels in worship before the time of the earthly realm, so they would have been acquainted with both of them and not had a reason to prefer one over the other. Many narrations about this beforetime also indicate the angels' acknowledgment of the Prophet (S) along with the rest of the Ahl al-Bayt (A) and not prioritizing one over another.