add new value for repair cod /hero-detail.component.ts
This commit is contained in:
parent
b0153ebb86
commit
80c0236f5e
|
@ -3,10 +3,11 @@ import { Component, OnInit } from '@angular/core';
|
||||||
import { Hero } from '../hero';
|
import { Hero } from '../hero';
|
||||||
import { HeroService } from '../hero.service';
|
import { HeroService } from '../hero.service';
|
||||||
import { RouterLink } from '@angular/router';
|
import { RouterLink } from '@angular/router';
|
||||||
|
import { HeroSearchComponent } from "../hero-search/hero-search.component";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard.component',
|
selector: 'app-dashboard.component',
|
||||||
imports: [CommonModule, RouterLink],
|
imports: [CommonModule, RouterLink, HeroSearchComponent],
|
||||||
templateUrl: './dashboard.component.html',
|
templateUrl: './dashboard.component.html',
|
||||||
styleUrl: './dashboard.component.css'
|
styleUrl: './dashboard.component.css'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
import { Observable, Subject } from 'rxjs';
|
import { Observable, Subject } from 'rxjs';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
debounceTime, distinctUntilChanged, switchMap
|
debounceTime, distinctUntilChanged, switchMap
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
import { Hero } from '../hero';
|
import { Hero } from '../hero';
|
||||||
import { HeroService } from '../hero.service';
|
import { HeroService } from '../hero.service';
|
||||||
|
import { CommonModule } from '@angular/common'; //добавил библиотеку
|
||||||
|
import { RouterLink } from '@angular/router'; //добавил библиотеку
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-hero-search',
|
selector: 'app-hero-search',
|
||||||
|
imports: [CommonModule, RouterLink],
|
||||||
templateUrl: './hero-search.component.html',
|
templateUrl: './hero-search.component.html',
|
||||||
styleUrls: [ './hero-search.component.css' ]
|
styleUrls: [ './hero-search.component.css' ]
|
||||||
})
|
})
|
||||||
|
@ -20,11 +21,6 @@ export class HeroSearchComponent implements OnInit {
|
||||||
|
|
||||||
constructor(private heroService: HeroService) {}
|
constructor(private heroService: HeroService) {}
|
||||||
|
|
||||||
// Push a search term into the observable stream.
|
|
||||||
search(term: string): void {
|
|
||||||
this.searchTerms.next(term);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.heroes$ = this.searchTerms.pipe(
|
this.heroes$ = this.searchTerms.pipe(
|
||||||
// wait 300ms after each keystroke before considering the term
|
// wait 300ms after each keystroke before considering the term
|
||||||
|
@ -38,9 +34,6 @@ export class HeroSearchComponent implements OnInit {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private searchTerms = new Subject<string>();
|
|
||||||
|
|
||||||
// Push a search term into the observable stream.
|
// Push a search term into the observable stream.
|
||||||
search(term: string): void {
|
search(term: string): void {
|
||||||
this.searchTerms.next(term);
|
this.searchTerms.next(term);
|
||||||
|
|
Loading…
Reference in New Issue