Please Help this error. I'm stuck with this error, I'm using angular6
Error: Cannot find a differ supporting object 'cuisine' of type 'string'. NgFor only supports binding to Iterables such as Arrays.
Code:
// category.component.ts
import { Component, OnInit } from '@angular/core';
import { DataService } from 'src/app/data.service';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-category',
templateUrl: './category.component.html',
styleUrls: ['./category.component.css']
})
export class CategoryComponent implements OnInit {
Categories$: Object;
page:number=0;
constructor(private route: ActivatedRoute, private data: DataService) {
this.route.params.subscribe(
params => this.Categories$ = params.category
);
}
ngOnInit() {
this.data.getCategory(this.Categories$).subscribe(
data => this.Categories$ = data["data"].restaurantCategories
// data => console.log(data["data"].restaurantCategories)
)
}
}
View File
<ng-container class="post_data_container" *ngFor="let cat of Categories$">
<ul class="restaurant_container">
<li style="float: left;">
<img src="{{ cat.imageURL }}" alt="">
<p>Name: {{ cat.name }}</p>
<p>Category: {{ cat.category }}</p>
<p>Description: {{ cat.description }}</p>
<button class="btn btn-success"><a routerLink="/restaurant/category/name/{{cat._id}}" style="color: #fff;">click test</a></button>
</li>
</ul>
</ng-container>
Here's my Data Service:
getCategory(categoryData){
return this.http.get('http://192.168.1.100:3001/api/restaurant/categories/'+categoryData)
}