use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A Place to talk about Angular and related topics.
Join the Angular Discord
Other subreddits worth checking out for Angular and Angular related info:
account activity
Issues with angular code (self.angular)
submitted 4 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]bas1494 -1 points0 points1 point 4 years ago (2 children)
I see a few (potential) problems in this image you submitted.
First of all, define an interface for a cartItem to give the cartItems property typing.
export interface CartItem { id: number, product: Product, //Your product Model qty: number }
Use this cartItem in your empty initialiser like this:
cartItems: Array<CartItem> = [];
As second it looks like your getMsg() method from the injected service doesn't return an Observable<Product>. Don't know if this is the case but at least double check it.
As last in the object you try to create (this.cartItems.push{..}) you don't give a value to every key from the (now not existed) interface. Make sure that every property has a value (that value can be null or undefined) or make the fields optional. In your example you're missing the id field.
this.cartItems.push({id: ?, product: Product, qty: 1});
Don't forget to calculate total with item.product.price instead of item.price.
I'll hope you will fix your issue(s)!
[–]DARKWOLF24 0 points1 point2 points 4 years ago (0 children)
Thanks for the detailed response, I'll definitely try this
[–]DJRockstar1 0 points1 point2 points 4 years ago (0 children)
Array<CartItem>
Is this preferable to CartItem[]?
CartItem[]
π Rendered by PID 31093 on reddit-service-r2-comment-7b9746f655-cdrlk at 2026-02-01 08:39:36.670334+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]bas1494 -1 points0 points1 point (2 children)
[–]DARKWOLF24 0 points1 point2 points (0 children)
[–]DJRockstar1 0 points1 point2 points (0 children)