Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* questo codice conta quanti tipi di auto esistono nella gallery.
- è tipo il count in ebay, quello che riguarda i filtri.
- es. coupè(2), jeep(4), sportive(6).
- */
- let cars = this.filteredCars.value;
- let types = this.types.value;
- for(let j=0;j<types.length;j++){
- let count = 0;
- for(let k=0;k<cars.length;k++){
- if(types[j].name == cars[k].type)
- count++;
- }
- types[j].count = count;
- }
- this.types.next(types);
- }
- /* qui di sotto il codice che ho riscritto io.
- mi da errore 'types.map is not a function'.
- non so se sia corretto il resto,
- ci sarà almento un'altro errore sempre che non sia sbagliato il concetto.
- */
- combineLatest(this.filteredCars, this.types)
- .pipe(
- map((filteredCars:any, types:any) => {
- filteredCars.map( (fc) => types.map( (ty:TypeCB) => ty.name == fc.type ? ty.count++ : null))
- }),
- tap(() => console.log('piped'))
- ).subscribe();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement