【发布时间】:2016-10-11 05:07:09
【问题描述】:
有没有办法在templateUrl 中加载动态网址。类似于下面的代码:-
@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 并应用逻辑从服务器获取。
感谢任何形式的帮助。
【问题讨论】:
-
是的,我以前遇到过。但它涉及在测试版中删除的@View 装饰器。因此我提到了 rc 版本。它需要创建假组件。必须有一些更干净的解决方法。
标签: typescript angular angular2-template angular2-components