在 Angular 2 中请求承诺作为模板
Request promise as a template in Angular 2
我正在考虑使用非Angular传输来异步加载模板(实际上,如果模板是字符串或来自请求的承诺,我想决定构建时间),比如
@Component({
directives: [],
selector: 'some',
template: System.import('./some-template!text')
})
export class SomeComponent {}
能否将承诺(来自请求)作为组件模板提供?
directives/components 有某种 templateProvider
功能吗?
模板类型为字符串,see source。
或者您可以使用
templateUrl: 'relative/path/from/index.html/some-template.html'
我尝试用 IIFE
和 System.import
用 no luck.
完成不可能的事情
您可以尝试使用 IIFE
和您自己的模块加载器来加载 templates
synchronously
。 asynchronously
我认为行不通。
See this,为什么要用IIFE
.
我正在考虑使用非Angular传输来异步加载模板(实际上,如果模板是字符串或来自请求的承诺,我想决定构建时间),比如
@Component({
directives: [],
selector: 'some',
template: System.import('./some-template!text')
})
export class SomeComponent {}
能否将承诺(来自请求)作为组件模板提供?
directives/components 有某种 templateProvider
功能吗?
模板类型为字符串,see source。
或者您可以使用
templateUrl: 'relative/path/from/index.html/some-template.html'
我尝试用 IIFE
和 System.import
用 no luck.
您可以尝试使用 IIFE
和您自己的模块加载器来加载 templates
synchronously
。 asynchronously
我认为行不通。
See this,为什么要用IIFE
.