get_the_ID() Not Working in Sage Controller

Generally, I think the way to handle that situation is to run the query in the Composer and build an array of values. Then you can iterate over that array in your view.

I often just do what you mentioned, where I put the function requiring the post id directly into the view.

Here is a similar post: Get data from view to composer from get_the_terms() - #2 by uraayush