How to create shopping cart in ionic.....?


#1

hey friends,

i m developing shopping app in ionic and i m new in ionic frmework,
my problem is i m creatin shopping cart and checkout and want to get item in my cart, but i can’t understand how to do…
so please suggest me.


#2

Hi Ashish,

What your looking for is an angular service. This will allow you to persist data across the application.


#3

yes, i know but i don’t understand how to implement shopping cart and how to add and remove items in my cart.


#4

So something like this :

.service('shoppingCart', function() {
var shoppingList = [];

this.addItem = function(item){
this.shoppingList.push(item);
};

this.deleteItem = function(item) {
// Remove an item from the list here
};

// etc
});


#5

Thanks Dear,
i have solve my problem.


#6

i solve shopping cart problem but one another problem is also accoutre.
this is dependency problem. i m create sidemenu app so services.js (file) is not by default not created so, i never be set dependency. i m also set link in index.html and i m declare dependency in app.js.
like. - angular.module(‘starter’, [‘ionic’, ‘starter.controllers’, ‘starter.services’])