Angular JS, ng-click I, Exercise 9/11... Stuck on step 4

Please help me find error in the code …

On second last line of the code cited below, Error message reads as “Expected an assignment or function call and instead saw an expression.” … Code in
MainController.js …

app.controller(‘MainController’, [’$scope’, function($scope){
$scope.title = ‘Top Seller Books’,
$scope.promo = ‘ABC Books Promotion’,
$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: ‘Speaking JavaScript’,
price: 27,
pubdate: new Date(‘2000’, ‘12’, ‘31’),
cover: ‘img/program-or-be-programmed’,
likes: 0
},
{
name: ‘Eloquent Javascript’,
price: 18,
pubdate: new Date(‘2001’, ‘12’, ‘31’),
cover: ‘img/program-or-be-programmed’,
likes: 0
}
],
$scope.plusOne = function(index){
$scope.products[index].likes += 1;
}
}]);

Code in index.html goes as gollows with error message reads as “Did you update the

?” …
<!doctype html>

<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}} </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>
        </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>

appreciate helping hands…

DasaAnudas.

Add a semi-colon here:

So you have:

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

I think you may change the comma i mark above . i use “//” to mark the position.
You can change 3 commas and add 1 semicolon in your code
I hope it will help.
The function of comma and semicolon is different. comma can be used inside of the [{} , {} , {} ],but may not be used between $scope.x $scope.y …

Very many thanks for half solution…

what about solution to error in index.html due to which NEXT button
remains inactive… The error reads as ? And the problematic code snippet in index.htm as given
below for your ready reference…

+{{product.likes}}

Please have a look to trace bug…

My code in index.html is the same with you.
maybe you can try to reload the page or try to change a browser.

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