TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Maureen Moore
NA
206
0
Convert Object into an Array
Aug 2 2020 9:53 AM
In development mode, items is an array but after I deploy the app, it turns into an object and I get the following error in the console:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
In the component:
items = [];
getStorageItems(): any[] {
try
{
return
JSON.parse(localStorage.getItem(
'items'
));
}
catch
(err) {
console.warn(err);
return
[];
}
}
ngOnInit():
void
{
this
.items =
this
.getStorageItems();
}
In the HTML:
<
tr
*
ngFor
=
"let item of items"
>
<
td
>
{{item.quantity}}
</
td
>
<
td
>
{{item.product_name }}
</
td
>
</
tr
>
Reply
Answers (
2
)
tagged input in primeng
Grand Totals Not Updating Upon Delete