Advertisement
Guest User

Untitled

a guest
Dec 8th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. (function(){
  2. var app= angular.module('store', []);
  3. app.controller('TestController', function(){
  4. this.products = gems;
  5. });
  6.  
  7. var gems = [
  8. {
  9. name:'Bitch',
  10. price: 0,
  11. description: 'is a bitch',
  12. canPurchase: true,
  13. reviews: [{
  14. stars: 5,
  15. body: "I love this gem so much I'd marry it!",
  16. author: "joe@example.org",
  17. createdOn: 1397490980837
  18. },
  19. {
  20. stars: 1,
  21. body: "I'd suck this gem cuz it sucks.",
  22. author: "tim@example.org",
  23. createdOn: 1397490980837
  24. }]
  25. },
  26. {
  27. name:'Madafaka',
  28. price: 666,
  29. description: 'is satan',
  30. canPurchase: true,
  31. reviews: [{
  32. stars: 5,
  33. body: "I love this gem!",
  34. author: "joe@example.org",
  35. createdOn: 1397490980837
  36. },
  37. {
  38. stars: 1,
  39. body: "This gem sucks.",
  40. author: "tim@example.org",
  41. createdOn: 1397490980837
  42. }]
  43. }
  44. ];
  45.  
  46. app.controller('PanelController',function(){
  47. this.tab = 1;
  48. this.selectTab=function(setTab){
  49. this.tab=setTab;
  50. };
  51. this.isSelected=function(thisTab){
  52. return this.tab === thisTab;
  53. };
  54. });
  55.  
  56. app.directive("reviewsPanel",function(){
  57. return{
  58. restrict:'E',
  59. templateUrl:'reviews-panel.html',
  60. scope:{
  61. product:'bind'
  62. },
  63. controller: function($scope){
  64. this.review = {};
  65. this.addReview = function($scope){
  66. $scope.product.reviews.push(this.review);
  67. this.review = {};
  68. };
  69. },
  70. controllerAs:'reviewsCtrl'
  71. };
  72. });
  73. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement