Skip to content

Commit

Permalink
dynamic classes
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbasile committed Jun 22, 2018
1 parent 44e0928 commit 7d9c021
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions index.html
Expand Up @@ -17,7 +17,7 @@ <h1>{{ header.toLocaleUpperCase() }}</h1>
<button class="btn btn-primary" :disabled="newItem.length === 0" @click="saveItem">Save Item</button>
</div>
<ul>
<li v-for="item in items">{{ item }}</li>
<li v-for="item in items" :class="{strikeout: item.purchased}" @click="togglePurchased(item)">{{ item.label }}</li>
</ul>
<p v-if="items.length === 0">Nice job! You've bought all your items.</p>
</div>
Expand All @@ -30,19 +30,37 @@ <h1>{{ header.toLocaleUpperCase() }}</h1>
header: 'shopping list app',
newItem: '',
items: [
'10 party hats',
'2 board games',
'20 cups',
{
label: '10 party hats',
purchased: false,
highPriority: false,
},
{
label: '2 board games',
purchased: true,
highPriority: false,
},
{
label: '20 cups',
purchased: false,
highPriority: false,
},
]
},
methods: {
saveItem: function() {
this.items.push(this.newItem);
this.items.push({
label: this.newItem,
purchased: false,
});
this.newItem = '';
},
changeState: function (newState) {
changeState: function(newState) {
this.state = newState;
this.newItem = '';
},
togglePurchased: function(item) {
item.purchased = !item.purchased;
}
}
})
Expand Down

0 comments on commit 7d9c021

Please sign in to comment.