app.js 530 B

12345678910111213141516171819202122
  1. (function () {
  2. var app = angular.module('store', ['store-products']);
  3. app.controller('StoreController', [ '$http', function ($http) {
  4. var store = this;
  5. store.products = [];
  6. $http.get('products.json').success(function(data) {
  7. store.products = data;
  8. });
  9. }]);
  10. app.controller('ReviewController', function () {
  11. this.review = {};
  12. this.addReview = function (product) {
  13. this.review.createdOn = Date.now();
  14. product.reviews.push(this.review);
  15. this.review = {};
  16. };
  17. });
  18. })();