By some theories (Carver and Scheier), positive emotions result when you are making progress towards a goal and negative emotions when you are not making progress towards a goal.
They differentiate between approach goals (desired end-states) and avoidance goals (undesired end-states that need to be avoided) and their research has shown that success/failure in approach and avoidance motivations/goals result in different emotions.
To simplify, as per their theory, anger (along with sadness) is associated with lack of progress in an approach motivation task. Fear is associated with lack of progress in escaping or avoiding the threat or undesired end-state. Both Anger and Fear are, in a sense, cognitive appraisals of how far (psychologically /physically) we are from a reward/threat respectively.
I write in detail about this, as well as an alternate model for what Anger and Fear code, in my recent PT blog post .