[AngularJS]15. Add reviewController

Create a ReviewController and inside of it an empty review ripe for the stuffing! Then below that create the functionality to create new reviews.

Create a new controller called ReviewController.

  app.controller('ReviewController', function(){
      
  });

 

Set our review variable to an empty object when the ReviewController is created.

  app.controller('ReviewController', function(){
    this.review = {};
  });

 

Create an empty function named addReview in your ReviewController.

  app.controller('ReviewController', function(){
    this.review = {};
    
    this.addReview = function(product){
        product.reviews.push(this.review);
      this.review = {};
    };
  });

 

posted @ 2014-07-27 18:45  Zhentiw  阅读(498)  评论(0)    收藏  举报