Since elements in group 1 only have 1 valence electron and elements in group 17 have 7 valence electrons, the one electron from the element in group 1 transfers to the group 17 element. That way, there are 8 valence electrons in this new bond, or a full outer energy level!