How is an ionic compound formed?

Ionic compounds are formed when two oppositely charged particles are attracted to each other.