Skip to content

Commit 4d6902c

Browse files
committed
show categories in categoryList without photo
1 parent bb210ef commit 4d6902c

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,19 @@
7373
<i class="fa fa-angle-right btn btn-default"></i>
7474
</div>
7575
<div class="full-width container-post">
76-
<!--
77-
{{#category}}
78-
<div class="full-width post">
76+
77+
<div *ngFor="let category of categories" class="full-width post">
7978
<figure class="full-width post-img">
80-
<img alt="" class="img-responsive" src="category/{{ID_CATEGORY}}/imagen">
79+
<img alt="" class="img-responsive" src="category/{{category.id_CATEGORY}}/imagen">
8180
</figure>
8281
<div class="full-width post-info">
83-
<a class="full-width post-info-price" href="/commercial/{{ID_CATEGORY}}">{{TITLE}}</a>
84-
<span class="post-info-zone">{{DESCRIPTION}}</span>
85-
<a class="post-info-date" href="/categoryList/{{ID_CATEGORY}}/delete">x</a>
82+
<a class="full-width post-info-price" href="/commercial/{{category.id_CATEGORY}}">{{category.title}}</a>
83+
<span class="post-info-zone">{{category.description}}</span>
84+
<a class="post-info-date" href="/categoryList/{{category.id_CATEGORY}}/delete">x</a>
8685

8786
</div>
8887
</div>
89-
{{/category}}
90-
-->
88+
9189
</div>
9290
</div>
9391
</div>
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,12 +7,22 @@ import {LoginService} from '../../services/login.service';
77
selector: 'categoryList',
88
templateUrl: './categoryList.component.html'
99
})
10-
export class CategoryListComponent {
10+
export class CategoryListComponent implements OnInit{
11+
12+
categories: Category[];
13+
1114
constructor(public categoryService: CategoryService, public loginService: LoginService) {
1215
}
16+
ngOnInit(): void {
17+
this.categoryService.getCategories().subscribe(
18+
category => this.categories = category,
19+
error => console.log(error)
20+
);
21+
}
1322

1423
addCategory(event: any, title: string, description: string, icon: string): void {
1524
event.preventDefault();
1625
this.categoryService.addCategory(title,description,icon);
1726
}
27+
1828
}

angular/wallypop/src/app/services/category.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class CategoryService {
3737
this.httpClient.post(BASE_URL + 'admin/categories', {title, description, icon}, {withCredentials: true})
3838
.subscribe(
3939
(response) => this.router.navigate(['profile']),
40-
(error) => alert('Usuario ya existe, inicie sesión')
40+
(error) => alert('Error al añadir categoria')
4141
);
4242
/*return this.httpClient.post(BASE_URL + 'admin/categories', {title, description, icon}, {withCredentials: true})
4343
.pipe(

0 commit comments

Comments
 (0)