A bit of research is the answer. Most problems with aggression in community tanks are caused by impulse buying and one of the nicest things about fish is that they don't tend to be too unpredictable - aggressive or fin-nipping species are normally well known for these tendencies.
Of course, many fishes only exhibit their normal behaviour when kept in the right numbers and this applies to shoaling species especially. Rogue behaviour is normally down to a lack of the right social conditions and single angelfish, male livebearers and many barbs can be problematic if not given an outlet for their normal social activity. Sometimes these problems only occur once fish are sexually mature and it's worth remembering that your aquatic pets have no choice over who they share a tank with and can hardly be blamed for compatibility issues.
A common scenario is one where cichlids such as angelfish pair off and defend a breeding territory. As long as the tank is large enough to accommodate this 'exclusion zone' then the other occupants can carry on with life in peace outside its borders. If your aquarium isn't large enough for this, then typically the parent fish will take matters into their own (metaphorical) hands.