在HeroService 類的構造函數(shù)中,我們通過 @Inject('apiUrl') 方式,注入 apiUrl 該 Token 對應的依賴對象,即 'http://localhost:4200/heros' 。為什么不能使用 private apiUrl: 'apiUrl' 的方式,希望讀者好好回憶一下,之前我們介紹過的相關內(nèi)容。以上代碼成功運行后,在 http://localhost:4200/ 頁面,我們將...
www.dbjr.com.cn/article/1153...htm 2025-6-8