Skip to content

Commit 5e785ce

Browse files
committed
show categories in category page
1 parent 3d7446d commit 5e785ce

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

angular/wallypop/src/app/components/category/category.component.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,14 @@ <h3 class="text-info">Busca una categoría</h3>
9090
<label>Busca categoría</label>
9191
</div>
9292
<div class="col-sm-7">
93-
<!--
93+
9494
<div class="form-group">
9595
<select class="form-control" name="lcategories">
96-
{{#lcategory}}
97-
<option name="ID_CATEGORY" value="{{ID_CATEGORY}}">{{TITLE}}</option>
98-
{{/lcategory}}
96+
<option *ngFor="let category of categories" name="ID_CATEGORY" value="{{category.id_CATEGORY}}">{{category.title}}</option>
9997
</select>
100-
<input name="_csrf" type="hidden" value="{{token}}"/>
101-
<input class="btn btn-default" type="submit" value="Buscar Categoria"></input>
98+
<input class="btn btn-default" type="submit" value="Buscar Categoria">
10299
</div>
103-
-->
100+
104101
<div class="form-group">
105102
<a href="categoryList">VER LISTADO CATEGORÍAS</a>
106103
</div>

angular/wallypop/src/app/components/category/category.component.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component} from '@angular/core';
1+
import {Component, OnInit} from '@angular/core';
22
import { Category } from 'src/app/models/category.model';
33
import {CategoryService} from '../../services/category.service';
44
import {LoginService} from '../../services/login.service';
@@ -7,10 +7,20 @@ import {LoginService} from '../../services/login.service';
77
selector: 'category',
88
templateUrl: './category.component.html'
99
})
10-
export class CategoryComponent {
10+
export class CategoryComponent implements OnInit{
11+
12+
categories: Category[];
13+
1114
constructor(public categoryService: CategoryService, public loginService: LoginService) {
1215
}
1316

17+
ngOnInit(): void {
18+
this.categoryService.getCategories().subscribe(
19+
category => this.categories = category,
20+
error => console.log(error)
21+
);
22+
}
23+
1424
addCategory(event: any, title: string, description: string, icon: string): void {
1525
event.preventDefault();
1626
this.categoryService.addCategory(title,description,icon);

0 commit comments

Comments
 (0)