9.2 ng-Click 1 can't find my error pls help!


#1

Hello! I don't know what's wrong :cry:

I also tried: adding +, checked every comma and spelling but I always recieved ERROR MESSAGE: Did you display the product's likes?

    <div ng-repeat="products in products" class="col-md-6"> 
      <div class="thumbnail">
        <img ng-src ="{{ products.cover }}">
        <p class="title">{{ products.name }}</p>
        <p class="price">{{ products.price | currency}} </p>
        <p class="date">{{products.pubdate | date}}</p>
      <div class="rating">
           <p class="likes">{{ products.likes }}</p>
	</div>
      </div>
    </div>

MAIN CONTROLLER

app.controller('MainController', ['$scope', function($scope) {
  $scope.title = 'Top Book Choices';
  $scope.promo = 'Top Background Song';
  $scope.products = [
    {
      name: 'The Book of Trees',
      price: 19,
      pubdate: new Date('2014', '03', '08'),
      cover: 'img/the-book-of-trees.jpg',
      likes: 0
    },
    {
      name: 'Program or be Programmed' ,
      price: 8,
      pubdate: new Date('2013', '08', '01'),
      cover: 'img/program-or-be-programmed.jpg',
      likes: 0
    },
    {
      name: 'Fifty Shades of Grey',
      price: 21,
      pubdate: new Date('2011', '04', '25'),
      cover: 'https://upload.wikimedia.org/wikipedia/en/5/5e/50ShadesofGreyCoverArt.jpg',
      likes: 0
    },
    {
      name: 'Harry Potter and the Prisoner of Azkaban',
      price: 57,
      pubdate: new Date('1999', '08', '08'),
      cover: 'https://upload.wikimedia.org/wikipedia/en/b/b4/Harry_Potter_and_the_Prisoner_of_Azkaban_(US_cover).jpg',
      likes: 0
    }
  ]
}]);

Thank you so much :kiss:


#2

Add a semi-colon on the second to the last square bracket, here.

Does this resolve?


#3

Edit the ng-repeat to replace the 1st products with product and also in all places which has {{ }}. I believe Angular is not able to differentiate between the variables as the names as the same.


#4

Hello @bayoishola20! Thanks for your reply I just replace "products" with "product" and it let me passed! I think there must be a problem with this because obvi the $scope has "products" not "product"!

Thanks again! :+1::revolving_hearts:


#5

You're welcome.

Yeah, I suspect same. That should be an error then. @allentv 's explanation is right!

Code on! :slight_smile:


#6

Hello @allentv! Yes, I thought there was some bug here. Spell check in coding is a MUST! :laughing:


#7

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