Ammonia becomes ammonium hydroxide when it reacts with water. They both work in hair dyes to alter the pH of the hair and prepare the hair to absorb the new colour.