add Update the HeroesComponent template
This commit is contained in:
parent
5c7de69dd5
commit
60cf72f36f
|
@ -0,0 +1,10 @@
|
|||
<div *ngIf="hero">
|
||||
|
||||
<h2>{{hero.name | uppercase}} Details</h2>
|
||||
<div><span>id: </span>{{hero.id}}</div>
|
||||
<div>
|
||||
<label for="hero-name">Hero name: </label>
|
||||
<input id="hero-name" [(ngModel)]="hero.name" placeholder="name">
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,17 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Hero} from '../hero';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'app-hero-detail',
|
||||
templateUrl: './hero-detail.component.html',
|
||||
styleUrls: ['./hero-detail.component.css'],
|
||||
imports: [CommonModule, FormsModule]
|
||||
})
|
||||
|
||||
export class HeroDetailComponent {
|
||||
@Input() hero?: Hero;
|
||||
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
<p>hero-detail works!</p>
|
|
@ -1,11 +0,0 @@
|
|||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-hero-detail',
|
||||
imports: [],
|
||||
templateUrl: './hero-detail.html',
|
||||
styleUrl: './hero-detail.scss'
|
||||
})
|
||||
export class HeroDetail {
|
||||
|
||||
}
|
|
@ -1,18 +1,12 @@
|
|||
<h2>My Heroes</h2>
|
||||
|
||||
<ul class="heroes">
|
||||
<li *ngFor="let hero of heroes">
|
||||
<button type="button" (click)="onSelect(hero)" [class.selected]="hero === selectedHero">
|
||||
<button [class.selected]="hero === selectedHero" type="button" (click)="onSelect(hero)">
|
||||
<span class="badge">{{hero.id}}</span>
|
||||
<span class="name">{{hero.name}}</span>
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div *ngIf="selectedHero">
|
||||
<h2>{{selectedHero.name | uppercase}} Details</h2>
|
||||
<div>id: {{selectedHero.id}}</div>
|
||||
<div>
|
||||
<label for="hero-name">Hero name: </label>
|
||||
<input id="hero-name" [(ngModel)]="selectedHero.name" placeholder="name">
|
||||
</div>
|
||||
</div>
|
||||
<app-hero-detail [hero]="selectedHero"></app-hero-detail>
|
|
@ -3,12 +3,13 @@ import { Hero } from '../hero';
|
|||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import {HEROES} from '../mock-heroes';
|
||||
import { HeroDetailComponent } from '../hero-detail/hero-detail.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-heroes',
|
||||
templateUrl: './heroes.component.html',
|
||||
styleUrls: ['./heroes.component.css'],
|
||||
imports: [CommonModule, FormsModule]
|
||||
imports: [CommonModule, FormsModule, HeroDetailComponent]
|
||||
})
|
||||
|
||||
export class HeroesComponent { //определяем класс со списком героев
|
||||
|
|
Loading…
Reference in New Issue