The formation of ionic bonds between barium and nitrogen is shown in the image attached.
The electrostatic attraction between the negatively charged nitride ions and the positively charged barium ions creates the ionic bond. Electrons from the metal move to the non-metal to form ionic bonds, which are common between metals and non-metals.
The barium atom will loose three electrons to the nitrogen atom in the course of the ionic bonding. This is how the compound in the image that is shown is formed here.