Dividing compounds into either ionic or covalent groups is a bit too simplistic when explaining chemical bonds. In order to be able to characterise such compounds, the terms used should be predominantly ionic or predominantly covalent.
This is all due to electronegativity, with the greater the difference between the electronegativity of atoms in the same molecule the greater the ionic character.
As a rule of thumb, an ionic bond can be characterised by an electronegativity difference greater than 2 whilst a covalent bond can be characterised by an electronegativity difference smaller than 1.
CO2 Difference: 3.5-2.5 = 1 (Covalent)
Na2O Difference: 3.5 – 1.0 = 2.5 (Ionic)
O2 Difference: 3.5 – 3.5 = 0 (Covalent)
KF Difference: 4.0 – 0.8 = 3.2 (Ionic)
AlCl3 Difference: 3.0 – 1.5 = 1.5 (Intermediate)