10. Ng-click ||


#1

Hello, the bot says "On the

element, make sure to use ng-click to call the minusOne() function." I don't understand why .. here my code :slight_smile:






<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>





Book End



<div class="main" ng-controller="MainController">
  <div class="container">

    <h1>{{ title }}</h1>
    <h2>{{ promo }}</h2>

   <div ng-repeat="product in products" class="col-md-6">
      <div class="thumbnail">
        <img ng-src="{{ product.cover}}">
        <p class="title">{{ product.name | uppercase}} </p>
        <p class="price">{{product.price | currency }}</p>
        <p class="date">{{product.pubdate | date }} </p>
       <div class="rating">
            <p class="likes" ng-click="plusOne($index)">+ {{ product.likes }} </p>
         <p class="dislikes" ng-click="minusOne($index)">{{ product.dislikes }}</p>

        </div>
      </div>
    </div>

  </div>
</div>

<div class="footer">
  <div class="container">
    <h2>Available for iPhone and Android.</h2>
    <img src="https://s3.amazonaws.com/codecademy-content/projects/shutterbugg/app-store.png" width="120px" />
    <img src="https://s3.amazonaws.com/codecademy-content/projects/shutterbugg/google-play.png" width="110px" />
  </div>
</div>


<!-- Modules -->
<script src="js/app.js"></script>

<!-- Controllers -->
<script src="js/controllers/MainController.js"></script>


JS

app.controller('MainController', ['$scope', function($scope) {
$scope.title = 'Nine';
$scope.promo = "The most popular books this month";
$scope.products = [
{ name: 'The Book of Trees',
price: 19,
pubdate: new
Date ('2014', '03', '08'),
cover: 'img/the-book-of-trees.jpg',
likes : 0,
dislikes :0,
},
{
name: 'Program or be Programmed',
price: 8,
pubdate: new
Date('2013', '08', '01'),
cover: 'img/program-or-be-programmed.jpg',
likes : 0,
dislikes :0
},
{ name: 'Mes choix',
price: 19,
pubdate: new
Date ('2014', '03', '08'),
cover: 'img/the-book-of-trees.jpg',
likes:0,
dislikes :0
},
{
name: 'Ma vie',
price: 8,
pubdate: new
Date('2013', '08', '01'),
cover: 'img/program-or-be-programmed.jpg',
likes : 0,
dislikes :0
},
];

$scope.plusOne = function(index) {
$scope.products[index].likes += 1;
};

$scope.minusOne = function(index) {
$scope.products[index].dislikes -=1;
};
}]);


#2

Your dislikes function is bad, because you want to plus one number to the Dislikes poperty and you have

`$scope.minusOne = function(index) {
$scope.products[index].dislikes -=1;
};

`
in this function what you are doing is to get a number less or equal to 1, but you want a number that is bigger or equal to 1, so use this one:

$scope.minusOne = function(index) {
$scope.products[index].dislikes +=1;
};

Excuse my bad english, i am not so good at it.