I'm trying to get data from another view, like this:
this.paramsSub = this.activatedRoute.params.subscribe(params => this.categories = params['obj']);
this.paramsSub = this.activatedRoute.params.subscribe(params => this.userInfo = params['usr']);
The data is sended in this way:
this.router.navigate(['/path/obj', {obj: this.categories, usr: this.userInfo}]);
I'm trying to show categories with a *ngFor in html like this:
<div *ngFor="let category of categories">
<input type="checkbox" value={{category.id}}/> {{category.name}}
</div>
My error:
Cannot find a differ supporting object '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]' of type 'string'. NgFor only supports binding to Iterables such as Arrays.
I go to another view good, but IDK why my error, if I try to: JSON.parse the error change to
Unexpected token o in JSON at position 1
Error: Error in :0:0 caused by: Unexpected token o in JSON at position 1
I have been reading about that error and it's look like I don't need the parse, so I'm very confusing.
Help, and thank you!
UPDATE
Here is the data before go to another view.
categories
is not a array. it is a object. – Smit