diff options
Diffstat (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts')
-rw-r--r-- | ufund-ui/src/app/components/need-list/need-list.component.ts | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts index 4409b63..b21979f 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.ts +++ b/ufund-ui/src/app/components/need-list/need-list.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import {Need} from '../../models/Need'; import {CupboardService} from '../../services/cupboard.service'; import { UsersService } from '../../services/users.service'; -import { userType } from '../../models/User'; +import { userType } from '../../models/User'; @Component({ selector: 'app-need-list', standalone: false, @@ -12,15 +12,19 @@ import { userType } from '../../models/User'; export class NeedListComponent { needs: Need[] = []; searchResults: Need[] = []; - + constructor( private cupboardService: CupboardService, private usersService: UsersService ) {} + refresh() { + this.cupboardService.getNeeds().subscribe(n => this.needs = n) + } + ngOnInit(): void { - this.cupboardService.getNeeds().subscribe(n => this.needs = n) - this.close(); + this.refresh() + // this.close(); } private showElement(element: any) { @@ -63,7 +67,7 @@ export class NeedListComponent { if (this.searchDelay) { clearTimeout(this.searchDelay); } - + this.searchDelay = setTimeout(() => { const currentSearchValue = form.search; //latest value of the search this.cupboardService.searchNeeds(currentSearchValue).subscribe((n) => { @@ -81,7 +85,7 @@ export class NeedListComponent { }, 250); } - delete(id : number) { + delete(id : number) { this.cupboardService.deleteNeed(id).subscribe(() => { this.needs = this.needs.filter(n => n.id !== id) }) |