What are ionic bonds?
Ionic bonding is the complete transfer of valence electron between atoms.
Ionic bonds are the bonds that are formed during the formation of electrovalent or ionic compounds.
This happens when a metallic atom reacts with a non-metallic atom.Electrovalent compounds are formed due to the high difference in electronegativities between the metallic atoms and the non-metallic atoms.
#Na#atom consists of 1 valence electron in its valence shell.
#Na#needs to lose this electron to attain octet configuration.
#Cl#atom consists of 7 valence electrons in its outermost shell. Thus, #Cl#needs to gain 1 valence electron to attain an octet configuration.
You can refer to the image for better understanding:
Hope it was of some help!!