I heard from my Rabbi a very interesting explanation given by Rabbi Menashe Klein in his work ספר הקנינים (Sefer HaKinyanim).
Rabbi Menashe Klein writes (Sefer HaKinyanim, p. 39):
להם יהושע וזה א"א רק ע"י שימוש שללמוד אפשר לכל אדם אבל לשמש ולדעת אופן הקיום צריך שימוש ולראות הלכה למעשה כיצד עשה משה רבינו וזה הוא המסורה שקבל יהושע ממשה רבינו לבד הלימוד שלמד עם כל ישראל מסר לו סודות התורה והתכמה וסודות ההנהגה לכלל ישראל בכל מכל כל אשר א"א ללמד את כל ישראל וזהו הנקרא מסורת אבות ואפילו לפעמים יבא מי שהוא לדייק באופן אתר מפי הלימוד והפלפול היפוך מסורה זו לא נאבה ולא נשמע לו ונדע כי פלפול זה שקר הוא כיון שקבלנו מפי משה רבינו וקבלה נאמנת במסורה איש מפי איש והפלפול הוא נבנה על אדני השקר ואישתבש אותו התכם שיצתה לו נגד הקבלה ולא ירד לעומקה של הלכה
There are many secrets in the Torah, also known as the inner aspect of Torah, or, as the Alter Rebbe explains (Tanya, Kuntres Acharon 6):
the internal aspect of the depth, which is the inner aspect of Torah — pnimiyut haTorah— is totally united with the blessed Infinite Light that is clothed within Torah
So, according to what Rabbi Menashe Klein explains in his Sefer HaKinyanim (p. 39), these "secrets of Torah", e.g. the inner dimension of the Torah where known to Yehoshua, but the entire nation received "the basic Torah Sheba'al Peh".
The concept that Yehoshua knew the inner dimensions of the Torah, the Sod, is explained in Kol HaTor (2:98) by Rabbi Hillel Rivlin, a disciple of the Vilna Gaon:
“The secret of the Lord is for those who fear him” (Ps. 25:14) -- Whenever the word is mentioned, it refers to the mission of Mashiach ben Yosef as hinted at in the verse: “place it into the ears of Joshua.” In gematria, ! in the ears of, equals [70] and when the value of the letters of as pronounced are added up [i.e., ' '], they equal [566].
When G-d spoke face-to-face to Moshe Rabbeinu, Yehoshua was always in the tent, as it says (Shemos 33:11):
but his attendant, Joshua son of Nun, a youth, would not stir out of the Tent.
This is also explained by N.T. where the Meiri is quoted
This is why Yehoshua was called binun, meaning “the understanding one,” (Ramban, Shemos 33:1)
See also these lengthy articles about Moshiach ben Yosef and Yehoshua.