In Scrum we look to create product increments each Sprint, not simply to do work. The direct solution to your question from the Scrum Guide is that you should have cross-functional team. That is, all skills needed to deliver a full product increment should be on the team.
There are circumstances where this may not be possible and you are stuck in the constraint. In that situation, you have to coordinate the efforts between the teams to manage the dependencies. However, in every case I've seen with front-end / back-end teams, there are far too many dependencies between them and it is far easier to just reform the teams to be cross-functional.