我是一名新手,正在尝试显示一个子组件,但输出的屏幕是空白的,甚至标题也没有显示。请帮忙解决。
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
子组件
import {Component} from '@angular/core';
@Component({
selector: 'app-test',
template: '<h1>Haa</h1>',
})
export class CAppComponent {
}
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { CAppComponent } from './child/child.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule, CAppComponent
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.html
<!--The whole content below can be removed with the new code.-->
<div style="text-align:center">
<h1>
Welcome to {{title}}!!
</h1>
<app-test></app-test>
</div>