I'm following the Tour of Heroes tutorial and cannot figure out why ngModel is not updating hero.name or if it's just not updating the view. I type into the input but the displayed name in the view remains the same (Windstorm).
Please let me know what I am doing wrong here.
heroes.component.html
<h2>{{ hero.name | uppercase }}</h2>
<div><span>id: </span>{{ hero.id }}</div>
<div>
<label>name
<input ([ngModel])="hero.name" placeholder="name">
</label>
</div>
heroes.component.ts
import { Component, OnInit } from '@angular/core';
import { Hero } from '../hero';
@Component({
selector: 'app-heroes',
templateUrl: './heroes.component.html',
styleUrls: ['./heroes.component.css']
})
export class HeroesComponent implements OnInit {
hero: Hero = {
id: 1,
name: 'Windstorm'
};
constructor() { }
ngOnInit() {
}
}
hero.ts
export class Hero {
id: number;
name: string;
}