Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: How to pass multiple values to angular 5 observable?


I am learning angular day by day but I am stuck on a problem. I have 3 values in one component and I need to Pass them to another component. I have basic understanding of observable and subscription but I have done it with 1 parameter. Now I want to broadcast 3 values

Here is my code of shopping cart.

this.itemscount = this.cart.length;

When I click on a product this function calls and it sends cart Array to observable and there I broadcast the cart array

export class DataService {

private cart = new BehaviorSubject([]);
cast = this.cart.asObservable();

constructor() { }

changeCart(item_param) {;


Now I need to pass 3 values to observable and I am confuse how to do it because I have read that we can pass only one value to observable. I had one idea to wrap all values in an array and pass that array but I search on this but could not find that how to store multiple values in single array in angular.

Any help would be highly appreciated.Thanks

Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered

This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: How to pass multiple values to angular 5 observable?


Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription