【发布时间】:2019-12-19 04:22:14
【问题描述】:
父组件.html
<div ["child-component"]> </div>
子组件.html
<div> This is a Child Component </div>
子组件.ts
import { Component } from '@angular/core';
import { FormBuilder } from '@angular/forms';
@Component({
selector: 'child-component',
templateUrl: './child.component.html',
styleUrls: ['./child.component.css']
})
export class ChildComponent{
constructor(private formBuilder: FormBuilder) {}
}
问题:ParentComponent 加载时不渲染子组件。
错误:控制台无错误,子组件中未命中调试点。
我尝试在 ParentComponentMoudle.ts 文件中包含 ChildComponentModule。
注意:我正在从 Angular 4 迁移到 8。
总结:我要做的就是在页面上加载一个非常基本的自定义组件
【问题讨论】:
-
嗨,伙计,你能提供更多代码吗?只有你的书面解释,人们什么也做不了。问候
-
你能提供你
ChildComponent.ts文件的前20行吗?应该有一个叫做selector的属性,它定义了你如何绑定到html中的组件。