我必须使用角度4过滤数据?它是一个女性服装网站。例如,我必须根据尺寸,颜色和袖长来过滤女性的T恤。所以有10 +尺寸,6 +颜色,3 +袖子长度。现在,如果我点击蓝色,那么应该显示所有女性的蓝色T恤,并且当我点击xl尺寸时也会显示尺寸,然后应该显示所有女性的xl T恤
app.component.html
<div class="col-md-6" id="sidebar">
<ul class="nav">
<li class="nav-item">
<a class="nav-link" routerlink="#submenu" data-toggle="collapse" (click)="toggle1()" data-target="#submenu">Color <mat-icon class="pull-right" >{{icon1 ? 'remove' : 'add' }}</mat-icon></a>
<div class="collapse" id="submenu" aria-expanded="false">
<ul class="nav" *ngFor="let colour of colours ">
<li class="nav-item"><a class="nav-link" (click)="Event(colour)" routerlink="/">{{colour.title}}</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" routerlink="#submenu2" data-toggle="collapse" data-target="#submenu2">sleeve-length <mat-icon class="pull-right" >add</mat-icon></a>
<div class="collapse" id="submenu2" aria-expanded="false">
<ul class="nav" *ngFor="let s of sleeve">
<li class="nav-item"><a class="nav-link" id={{s.id}} routerlink="/">{{s.title}}</a></li>
</ul>
</div>
</li>
<li class="nav-item">
<a class="nav-link" routerlink="#submenu3" data-toggle="collapse" data-target="#submenu3">sizes<mat-icon class="pull-right" >add</mat-icon></a>
<div class="collapse" id="submenu3" aria-expanded="false">
<ul class="nav" *ngFor="let size of length">
<li class="nav-item"><a class="nav-link" id={{size.id}} routerlink="/">{{size.title}}</a></li>
</ul>
</div>
</li>
</ul>
</div>
<div class="col-sm-6 col-md-4" *ngFor="let x of httpdata; let i = index; ">
<div class="panel panel-default">
<div class="panel-body">
<img src="{{x.product_image}}" height="300px" width="200px">
</div>
</div>
</div>
app.component.ts
export class AppComponent implements OnInit {
constructor(private dataservice:DataserviceService,private global: AppGlobals){}
httpdata;
colours;
sleeve;
length;
ngOnInit() {
this.dataservice.getApparel(this.global.AppUrl +'getRecommendations?client=web&call_tag=stylemachine&size=15&position=0&attempt=0&user=5724&project=2226&collection=200&category=16&client-tag=women_apparels').subscribe(data=>this.httpdata=data);
this.dataservice.getFilter(this.global.AppUrl +'availableFilters?client=web&category=16').subscribe(colours=>this.colours=colours);
this.dataservice.getSleeve(this.global.AppUrl +'availableFilters?client=web&category=16').subscribe(sleeve=>this.sleeve=sleeve);
this.dataservice.getLength(this.global.AppUrl +'availableFilters?client=web&category=16').subscribe(length=>this.length=length);
}
Event(colour) {
console.log(colour);
}
}
答案 0 :(得分:0)
我在IONIC 3制作的应用程序中使用了一个Pipes来制作这种搜索和排序规则。
您可以查看如何在角度4中制作PIPES。
否则,我可以给你一些例子。