Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- a: { name: 'A', date: '1/2/03', number: 1},
- b: { name: 'B', date: '4/5/06', number: 2},
- }
- [{
- id: 0,
- name: 'Category 1',
- items: [{
- id: 0,
- name: 'A1',
- state: state.MIN
- },{
- id: 1,
- name: 'B1',
- state: state.MIN
- },...
- <body ng-controller="MainCtrl">
- <h3>Size & state</h3>
- <div ng-repeat="collection in data">
- <h4 ng-bind="collection.name"></h4>
- <span ng-repeat="item in collection.items">
- <button ng-bind="item.name"
- ng-class="{ med: item.state, max: item.state == 2 }"
- ng-click="changeState(collection, item)">
- </button>
- </span>
- </div>
- </body>
- .med {
- width: 85px;
- height: 85px;
- }
- .max {
- width: 110px;
- height: 110px;
- }
- switch(item.state) {
- case state.MIN:
- _.each(collection.items, function(current) {
- current.id == item.id ? current.state = state.MED : current.state = state.MIN;
- });
- break;
- case state.MED:
- item.state = state.MAX;
- break;
- default:
- item.state = state.MIN;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement