为什么我的 Angular 应用的 html 代码中的花括号没有编译其中的内容?

Why are the curly braces in my Angular app's html code not compiling what is inside of them?

我刚刚开始 Angular 的冒险,我遇到了一个问题。我知道您可以在 app.components.ts 中创建一个 属性 并通过将其名称放入花括号中以 html 代码显示它,它应该在我的网站上输出 属性万一它不起作用而我实际上一无所知。那是我的 app.components.ts:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'AngularCV';
}

我想在我的 html 代码中使用名为 "title" 的 属性。我的 app.component.html:

<div>
    {{title}}
</div>

在 运行 实时服务器之后,浏览器会准确显示我输入的内容而无需编译,所以 “{{title}}”是我在网页上看到的,而不是 "AngularCV" 我搜索了类似的问题,但没有任何效果。也许这是微不足道的,但我现在很困惑。

好的,我刚刚创建了一个全新的 angular 应用程序,并修改了我当前的 html 文件以匹配在全新应用程序中创建的文件。一切正常。据我所知,src/index.html 应该只包含头部和带有标记的空体。而除了头部之外的所有东西都应该放入app.component.html。希望对以后的人有所帮助。