Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. {
  2. a: { name: 'A', date: '1/2/03', number: 1},
  3. b: { name: 'B', date: '4/5/06', number: 2},
  4. }
  5.  
  6. [{
  7. id: 0,
  8. name: 'Category 1',
  9. items: [{
  10. id: 0,
  11. name: 'A1',
  12. state: state.MIN
  13. },{
  14. id: 1,
  15. name: 'B1',
  16. state: state.MIN
  17. },...
  18.  
  19. <body ng-controller="MainCtrl">
  20. <h3>Size & state</h3>
  21.  
  22. <div ng-repeat="collection in data">
  23. <h4 ng-bind="collection.name"></h4>
  24. <span ng-repeat="item in collection.items">
  25. <button ng-bind="item.name"
  26. ng-class="{ med: item.state, max: item.state == 2 }"
  27. ng-click="changeState(collection, item)">
  28. </button>
  29. </span>
  30. </div>
  31. </body>
  32.  
  33. .med {
  34. width: 85px;
  35. height: 85px;
  36. }
  37.  
  38. .max {
  39. width: 110px;
  40. height: 110px;
  41. }
  42.  
  43. switch(item.state) {
  44. case state.MIN:
  45. _.each(collection.items, function(current) {
  46. current.id == item.id ? current.state = state.MED : current.state = state.MIN;
  47. });
  48. break;
  49. case state.MED:
  50. item.state = state.MAX;
  51. break;
  52. default:
  53. item.state = state.MIN;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement