Your First App 10. ng-click II


#1


Here is the link to the exercise:
https://www.codecademy.com/courses/learn-angularjs/lessons/your-first-app/exercises/your-first-app-ng-click-ii

I get the following error: "Make sure the set the dislikes property to 0."
But I think I did that. And I really think I did that right too. So I'm not sure what its problem is. I checked comma's, semi-colons, all the brackets, curly or otherwise... The built-in debugger doesn't highlight anything.
I'm sure it must be something totally insignificant (since that is mostly the case when my code doesn't run...) but this time I can't really find the issue.
Does anybody have any suggestions?

(PS
Did anybody else notice that after changing from $scope.product to $scope.productS? I didn't change anything in my HTML (product.name etc), suspecting the code wouldn't run. But I was surprised it did, because I think it really shouldn't....)

Anyway, my script is as follows:

app.controller('MainController', ['$scope', function($scope) {
  $scope.title = 'The best surfspots in the world';
  $scope.promo = 'Where would you want to go?';
  $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: 'The Crossroads of Should and Must',
       price: 12,
       pubdate: new Date('2015', '04', '07'),
       cover:' https://d17lzgq6gc2tox.cloudfront.net/product/three_d_cover_image/original/9780761184881_3D.png?1475036275',
       likes: 0,
       dislikes: 0
      },
    {
      name: 'The Monk Who Sold His Ferrari',
      price: 15,
      pubdate: new Date('1996', '05', '10'),
      cover:'http://portuguesewaves.com/wp-content/uploads/2016/10/Buarcos.jpg',
      likes: 0,
      dislikes: 0
    },
    $scope.plusOne = function(index) {
      $scope.products[index].likes += 1;
    }
    
    ];
}]);

Plus the HTML it concerns:

<div ng-repeat="product in products" class="col-md-6">
          <div class="thumbnail">
            <img ng-src="{{ product.cover }}">
            <p class="title"> {{ product.name }} </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"> {{ product.dislikes }} </p>
            </div>
          </div>
        </div>

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.