【发布时间】:2017-03-09 18:25:27
【问题描述】:
我想使用嵌套组件。 这个很好的教程显示,我怎么能这样做:
https://www.themarketingtechnologist.co/building-nested-components-in-angular-2/
我的问题是,找不到嵌套组件的模板: 我试过了
template: '<h2>HALLO</h2>'
但我想像这样使用 extern 文件:task.component.html:
template: 'file.component.html'
输出就是,简单的
task.component.html
将显示 当我尝试时:
templateUrl: 'file.component.html'
我得到错误:
未捕获(承诺):未能加载 task.component.html
这是我的代码:
子组件:
@Component({
selector: 'edit-task',
templateUrl: 'file.component.html'
})
export class FileFormat{}
父组件:
@Component({
moduleId: module.id,
selector: 'my-app',
templateUrl: 'app.template.html',
directives: [FileFormat]
})
export class FileFormat{}
【问题讨论】:
标签: angular nested components