Never fear, your little one doesn't hate you and probably doesn't REALLY prefer your ex over you....he just doesn't know how, or even what, he's feeling now at this age.
My DS4 goes through this...even when it's just a phone call from his daddy.
They get angry at the other parent for not being there all the time or that they "go away" from them.
Actually, please feel loved that your little one can be angry with you because he KNOWS that the love between you two is stong enough to endure his anger.
Start giving his feelings a name..."Honey, I know what you're feelling is angry. It's ok to miss your daddy. I miss my daddy sometimes too. BUT you'll see him again." And let him cry in your arms if he needs to.
He may not cry right now at his age; that's when he needs a little space after you've given his emotion a name and the permission to feel that way.
After a day (or it may be several days sometimes - like with mine) that he'll come back around to the loving, happy child you know.
It's not easy, but think about times when fun things are taken away from you as an adult. Even WE go through the grumpies and need to work through them.
It may take tons of times to get him to understand that what he's feeling is anger, but starting eary at 2 will make it easier in the long run.
: to you. It's hardly ever easy to see this in the middle of being pushed away, but try to remember that his bond with you will be stronger in the long run because of this....because you were the one that gave him permission to feel what he needed to feel and were there to help "pick up the pieces" and provide security.
Love to you...I feel your pain.