diff options
| author | sowgro <tpoke.ferrari@gmail.com> | 2025-02-26 21:31:52 -0500 | 
|---|---|---|
| committer | sowgro <tpoke.ferrari@gmail.com> | 2025-02-26 21:31:52 -0500 | 
| commit | 8811480c199b7b2a97ee0532d3488ed9512b6f37 (patch) | |
| tree | 3c32ee0a82516492f0954f88404326e368e4c7f1 /ufund-ui/src/app/components | |
| parent | 8a2d6c332a089c2dbb7351514499e16f343959ff (diff) | |
| download | JellySolutions-8811480c199b7b2a97ee0532d3488ed9512b6f37.tar.gz JellySolutions-8811480c199b7b2a97ee0532d3488ed9512b6f37.tar.bz2 JellySolutions-8811480c199b7b2a97ee0532d3488ed9512b6f37.zip  | |
get angular services working
Diffstat (limited to '')
5 files changed, 36 insertions, 2 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.html b/ufund-ui/src/app/components/cupboard/cupboard.component.html index bcddb33..056c167 100644 --- a/ufund-ui/src/app/components/cupboard/cupboard.component.html +++ b/ufund-ui/src/app/components/cupboard/cupboard.component.html @@ -1 +1,2 @@  <p>cupboard works!</p> +<app-need-list></app-need-list> diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html index d366ee6..6e48d96 100644 --- a/ufund-ui/src/app/components/need-list/need-list.component.html +++ b/ufund-ui/src/app/components/need-list/need-list.component.html @@ -1 +1,6 @@ -<p>need-list works!</p> +<h1>Needs List</h1> +<li *ngFor="let need of needs"> +    <a routerLink="/need/{{need.id}}"> +        {{need.name}} +    </a> +</li> 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 61ed089..a3eb072 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 @@ -1,4 +1,6 @@  import { Component } from '@angular/core'; +import {Need} from '../../models/Need'; +import {CupboardService} from '../../services/cupboard.service';  @Component({    selector: 'app-need-list', @@ -7,5 +9,13 @@ import { Component } from '@angular/core';    styleUrl: './need-list.component.css'  })  export class NeedListComponent { +  needs: Need[] = []; +  constructor( +    private cupboardService: CupboardService +  ) {} + +  ngOnInit(): void { +    this.cupboardService.getNeeds().subscribe(n => this.needs = n) +  }  } diff --git a/ufund-ui/src/app/components/need-page/need-page.component.html b/ufund-ui/src/app/components/need-page/need-page.component.html index ed5b6d8..0bc4746 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.html +++ b/ufund-ui/src/app/components/need-page/need-page.component.html @@ -1 +1,7 @@ -<p>need-page works!</p> +<h1>Need page</h1> +<p>id: {{need?.id}}</p> +<p>name: {{need?.name}}</p> +<p>filterAttributes: {{need?.filterAttributes}}</p> +<p>type: {{need?.type}}</p> +<p>max goal: {{need?.maxGoal}}</p> +<p>current: {{need?.maxGoal}}</p> diff --git a/ufund-ui/src/app/components/need-page/need-page.component.ts b/ufund-ui/src/app/components/need-page/need-page.component.ts index 390bfb6..15c1e87 100644 --- a/ufund-ui/src/app/components/need-page/need-page.component.ts +++ b/ufund-ui/src/app/components/need-page/need-page.component.ts @@ -1,5 +1,7 @@  import {Component, Input} from '@angular/core';  import {Need} from '../../models/Need'; +import {ActivatedRoute} from "@angular/router"; +import {CupboardService} from "../../services/cupboard.service";  @Component({    selector: 'app-need-page', @@ -8,5 +10,15 @@ import {Need} from '../../models/Need';    styleUrl: './need-page.component.css'  })  export class NeedPageComponent { +  constructor( +     private route: ActivatedRoute, +     private cupboardService: CupboardService, +  ) {} +    @Input() need?: Need; + +  ngOnInit(): void { +    const id = Number(this.route.snapshot.paramMap.get('id')); +    this.cupboardService.getNeed(id).subscribe(n => this.need = n); +  }  }  | 
