1
有沒有辦法在templateUrl
中加載動態URL。類似下面的代碼: -在組件的模板中加載動態URL URL Angular 2.0.0-rc.1
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: DynamicUrl, //Load DynamicUrl here
styleUrls: ['app.component.css']
})
export class AppComponent{
var DynamicUrl= 'app.component.html';
// ideally this template name will be pulled from the server.
}
我感到困惑的生命週期。在哪裏初始化和定義DynamicUrl並應用邏輯從服務器獲取。
任何形式的幫助表示讚賞。
這可能有助於http://stackoverflow.com/questions/31692416/dynamic-template-urls-in-angular-2 –
亞我來到翻過之前。但它涉及@視圖裝飾器,它被放入測試版。因此我提到了rc版本。它需要創建假組件。必須有一些更清潔的解決方法。 –