如何将组件放在Angular 2中的另一个组件的templateUrl中?

问题描述 投票:-1回答:1

如果我在Angular4父组件中使用templateUrl,我需要包含

父模板中的子组件,如<child></child>

我该如何实现同样的目标?

@Component({
  selector: 'parent',
  templateUrl: './foo.parent.html'
})
export class ParentComponent {}

子组件

@Component({
  selector: 'child',
  template: `
    <h4>Child Component</h4>
  `
})
export class ChildComponent {}
angular angular2-directives
1个回答
3
投票

<child></child>文件中添加foo.parent.html

© www.soinside.com 2019 - 2024. All rights reserved.