Never type the word function inside the body of one. Use fat arrow functions instead. Put the mapModal stuff inside the then block, in which doc is valid. Try to avoid putting doc into a controller property (myData). const in JavaScript is IMHO worthless, so I would simply use let everywhere you have const.
first i think it has to do with the scope of myData
you dont declare it until inside the IF-THEN statement, and then go on to use it outside. I would start with
let docRef = firebase.firestore().collection("posts").doc(post.id);
let myData: any;
if (doc.exists) {
console.log("Document data:", doc.data());
myData = doc.data();
console.log("My data:", myData);
or I would try moving the modal creating to within the if block. I assume you do not want the modal to show if no data comes through?
this would also take care of the scope issue
The error here looks like you may be getting data that is not iterable, firebase usually gives us observables. try just logging to see what the data coming back looks like
well, if I wrap it in JSON.Stringify() it outputs as what I believe would be iterable data but then I run into other errors about can’t iterate through a string and something about the *ngFor loop