Ionic bonding happens when an atom loses an electron (either by having it stolen or by giving it away) to an atom that needs another electron to get 8 valence electrons (the electrons on the outer shell). An atom that loses an electron becomes a cation, or a positive ion of that element. An atom that gets an electron becomes an anion, or negative ion. Opposites attract, so they bond.