【发布时间】:2019-10-14 08:40:13
【问题描述】:
我在 Angular 中有一个场景,我需要为同一个组件 ts 文件使用不同的 HTML 模板,就像这样
let templateUrl: string;
switch (environment.country) {
case 'India':
templateUrl = './comp1-in.component.html'
break;
case 'Brazil':
templateUrl = './comp1-br.component.html'
break;
default:
templateUrl = './comp1.component.html';
break;
}
@Component({
selector: 'app-comp1',
templateUrl: templateUrl,
styleUrls: ['./comp1.component.scss']
})
但这并没有按预期工作,它只是在视图中呈现模板路径而不是使用模板
【问题讨论】:
标签: angular typescript angular8