It is said that the Egyptian Empire was built upon the backs of slaves. While most of the Hebrews were slaves to Egypt in the time of Moses and Joshua, there were also those who were not. Because of Joshua's military prowess, it is speculated that he could have been a soldier or an officer in the Egyptian army prior to the Exodus. Regardless, it is evident that he did not trust in military might but trusted God wholly.
While in Egypt, Joshua saw all the signs and plagues inflicted upon the Egyptians. He was also an eyewitness to the awesome power and strength of God as the Egyptian army was swallowed by the Red Sea. Forty years in the wilderness he beheld God's provision of manna and clothes that would never wear out. He saw the earth swallow the disobedient and rivers of water spring forth from a rock. His preparation and training was never about his abilities but rather a focus on God's ability and strength.
The battle with the Amalekites proved Joshua's skills as a military general but it was his servant heart that granted him favor with God and Moses. He was obedient to Moses' command and met the Amalekites on the battlefield.
During the battle, Joshua knew that his victory lied within God's power and the steadiness of Moses' hand. When Moses raised up the staff of God the Israelites had the upper hand and when he lowered it the Amalekites would gain leverage. Choosing to fight this battle required trust and obedience. Being asked to do battle with Amalek is evidence of Joshua's already proven character and servanthood.
Courage, servanthood, obedience and faith are qualities that make leaders. Joshua is a great example of a man who did not trust in his own abilities but trusted in God's strength to bring forth victory. When we allow God to take the reins in our lives, our hopeless battles become sure wins.