2017-06-06 108 views
1

我試圖將我的應用從baseURL遷移到rootURL路由器配置。我堅持確定哪些url用於存儲在我的模板中的public/assets中的圖像。在模板中填充rootURL

在我使用assets/images/myimage.png之前,現在我想要做一些類似{{rootURL}}assets/images/myimage.png的操作,但是從路由中注入它看起來相當不方便。

setupController(controller, model) { 
    this._super(controller, model); 
    this.controllerFor('application').set('rootURL', this.get('router.rootURL')); 
} 

是否有既定的方法來做到這一點?

在此先感謝。

+0

可以導入像'從「應用程序名稱/配置/ environment''進口配置和使用它像'config.rootURL' – kumkanillam

+0

這似乎更優雅。謝謝。 – Luka

回答

2

可以導入像import config from 'app-name/config/environment'和使用它像config.rootURL