Adding items to cart ionic framework
<p>I am having trouble adding products (playlists) to the cart. I am not able to understand the reason behind this. I am new to ionic framework and angular js.
Can anyone please help me out with this. </p>

<p>THis is my code for cart.html</p>

<pre><code> &lt;ion-view view-title="Cart"&gt;
&lt;ion-content&gt;
  &lt;ion-list&gt;


  &lt;ion-item item-width = "50%" ng-repeat="product in cart track by $index"  &gt;
  &lt;p class='product-title'&gt;Item: {{product.title}}  &lt;/p&gt;  
  &lt;p class='product-price'&gt;Price:{{product.price}}&lt;/p&gt; 
  &lt;p class='product-amount'&gt;&lt;input type = "number" min = "0" placeholder = "0" value = "0" ng-model = "amount"&gt;&lt;/p&gt;
  &lt;span class = 'product-total'&gt;{{product.price*amount}}  &lt;/span&gt;



   &lt;/ion-item&gt;


&lt;/ion-list&gt;
   &lt;button class = "button button-small" ng-click = "payment()" &gt;Proceed to  Payment &lt;/button&gt; 
&lt;/ion-content&gt;
&lt;/ion-view&gt;
</code></pre>

<p>THis is my code for playlists.html</p>

<pre><code>&lt;ion-view view-title="Playlists"&gt;
  &lt;ion-content&gt;
 &lt;ion-list&gt;


 &lt;ion-item item-width = "50%" ng-repeat="playlist in playlists track by $index" &gt; 
 &lt;div class = "row"&gt;
  &lt;div class = "col"&gt;Item: {{playlist.title}}&lt;/div&gt;
 &lt;div class = "col"&gt;Price:{{playlist.price}}&lt;/di            &lt;/div&gt;    
&lt;ion-option-button class = "button-positive" ng-click =    "addtocart(playlist)" &gt;Add to Cart&lt;/ion-option-button&gt; 
 &lt;ion-option-button class = "button-assertive" ng-click =  "removefromcart(playlist)" &gt;Remove from Cart &lt;/ion-option-button&gt; 

     &lt;/ion-item&gt;

  &lt;/ion-list&gt;

&lt;/ion-content&gt;
&lt;/ion-view&gt;
</code></pre>

<p>THis is my code for  controllers.js </p>

<pre><code> .controller('PlaylistsCtrl', function($scope) {
 $scope.playlists = [
{ title: 'Reggae', price: '10' , id: 1 },
{ title: 'Chill', price: '10', id: 2 },
{ title: 'Dubstep', price: '10', id: 3 },
{ title: 'Indie', price: '10', id: 4 },
{ title: 'Rap', price: '10', id: 5 },
{ title: 'Cowbell', price: '10' , id: 6 }
];

   $scope.cart = [];
  $scope.addtocart = function(playlist){


  var productInCart = false;
  $scope.cart.forEach(function(prod, index, prods){
    if (prod.id === playlist.id) {
      productInCart = prod;
      return;
    }
  });

  if (productInCart) {
    //do nothing
  } else {
    $scope.cart.push(playlist);
  }
};


 $scope.removefromcart = function(playlist){

$scope.cart.forEach(function(prod, i, prods){
    if (playlist.id === prod.id) {
      $scope.cart.splice(i, 1);

    }
  });

 };
</code></pre>