It sounds like you did the right thing by ignoring the dog and walking away.
The only things I can say are 1. do not stare at the dog. It may see this as a challenge. and 2. Remain calm. Don't run away. If you run you become either a toy or prey.