zl程序教程

您现在的位置是:首页 >  其它

当前栏目

[AngularJS]15. Add reviewController

15 angularjs add
2023-09-14 09:00:56 时间

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 = {};
    };
  });