Skip to content

Instantly share code, notes, and snippets.

@fguisso
Created April 4, 2017 06:47
Show Gist options
  • Save fguisso/e6b40aaf5a2f8ad13462c4ada2081c74 to your computer and use it in GitHub Desktop.
Save fguisso/e6b40aaf5a2f8ad13462c4ada2081c74 to your computer and use it in GitHub Desktop.
export default {
name: 'users-view',
data: () => ({
userList: [],
checkedIds: [],
allSelected: false,
}),
beforeMount() {
this.http.get('/users/list')
.then((res) => {
this.userList = res.data;
});
},
watch: {
checkedIds: {
handler() {
this.allSelected = (this.userList.length === this.checkedIds.length);
},
deep: true,
},
},
methods: {
changeAll() {
this.checkedIds.forEach((checkbox, index) => {
checkbox = this.all;
this.checkedIds[index] = checkbox;
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment