All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
The belief of Ahlus-Sunnah Wal-Jamaa'ah in the field of Al-Qadr (predestination) is that Allaah has decreed the destiny of all the creatures 50,000 years before He created the heavens and the Earth as confirmed in an authentic Prophetic narration. This means that He knew what will happen and recorded it in the Preserved Book. Nothing happens except with His Will and Creation. These are the four stages of predestination: Knowledge, Writing, Will and Creation. So knowledge is the first stage of predestination; Allaah says (which means): {Do you not know that Allaah knows what is in the heaven and Earth? Indeed, that is in a Record. Indeed that, for Allaah, is easy.}[22: 70].
It is true that the angel writes the destiny of the foetus while the latter is still in the womb of his mother, as reported in a narration by Al-Bukhari and Muslim but nothing of this happens except with the permission of Allaah. It is stated in a narration that the angel asks Allaah: "O my Lord! Will he be happy or miserable, male or female." So the angel has no power or control over this matter, either concerning what is happening in the womb or what happens later.
Allaah knows best.