Electronegativity:
It is the tendency of an atom of an element to attract the shared pair of electrons towards itself in a covalent bond.
An ionic bond is formed by lose and gain of electrons within the elements involved. The low electronegativity of metals and high electron negativity of non-metals means that the energy change of the reaction is most favourable when metals lose electron(s) and non metals gain electron(s). The larger the difference in electronegativity between two atoms, the more ionic the bond.