Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70915

How do I store my count value in locally in the ionic app?

$
0
0

@shashankverma12 wrote:

Hi guys I am working on this live project where I want to store the quantity/count values (1,2,3…) locally. I just need a little guidance with the code. I am learning ionic. This is my ts files code snippet.

this.cartArr.push(items);
        this.dataPrint = this.cartArr;
        let item =this.dataPrint;
        let selected = {};

            for(let obj of item){
            if(selected[obj.ITEMID]){
              selected[obj.ITEMID].count++;
            }else{
              selected[obj.ITEMID] = {...obj,count: 1};
            }
          }

      this.selectedItems = Object.keys(selected).map(key => selected[key])
      console.log('items: ',this.selectedItems);
      this.total = this.selectedItems.reduce((a, b) => a + (b.count * b.RATE), 0);
      this.storage.set('cartItems',this.selectedItems);

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70915

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>