Just dipping my toes into the world of AngularJS, specifically with ionic.
I'm attempting to create an app that fetches 'posts' and then retrieves 'users' based on the post's user_id.
I have a service named "Posts" which sends an API request to fetch all posts using Posts.get(); function. The controller assigns the arraylist $scope.posts = Posts.all() to store the fetched posts.
Using ng-repeat, I can display each post id as they are received, and this part works smoothly.
However, I am struggling with downloading each user associated with post.user_id and linking them together.
When I try to inject the Users model into Posts and vice versa to enable them to interact with each other, it triggers a "Circular Dependency" error.
If I attempt to inject $scope into the models in order to call a function on the controller to connect them, it throws an "Unknown Provider $scopeProvider" error.
What is the correct approach to tackle such a scenario in AngularJS?
Fetch a post, retrieve the associated user information, and finally display both on the screen for the respective post and user.
Any help or guidance on this matter would be greatly appreciated! Thanks in advance!