《英雄之旅》中的模块不会更新

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

我正在angular.io上进行官方的“英雄巡回” Angular教程。

添加了名为“ heroes”的模块并显示它之后,一切都很好。 heroes.component.html仅包含一个p标签,上面写着“英雄作品!”。更改后,我的应用程序将得到更新,但不会更新heroes.component.html中所做的更改。因此,即使项目中的任何地方都不再写“ heroes works”,应用程序仍会显示该消息。非常感谢您的帮助。

heroes.component.ts:

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

@Component({
  selector: 'app-heroes',
  templateUrl: './heroes.component.html',
  styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {

 hero = 'windstorm';

 constructor() { }

 ngOnInit() {
 }

}

heroes.component.html:

<h2>{{hero}}</h2>>

app.component.html:

<h1>{{title}}</h1>
<app-heroes></app-heroes>

app.component.ts:

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

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

app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HeroesComponent } from './heroes/heroes.component';

@NgModule({
  declarations: [
    AppComponent,
    HeroesComponent
  ],
  imports: [
    BrowserModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

enter image description here

angular typescript angular-tour-of-heroes
1个回答
0
投票

将快速的操作从顶部移开。

[<h2>{{hero}}</h2>**>**删除组件的html文件中多余的大于号。

您可以发送文件结构的屏幕快照吗?

[尝试在Chrome的隐身窗口中打开应用程序,以确保完全清除缓存。

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