Simple Vue 2.0 Select All Checkbox

Simple Vue 2.0 Select All Checkbox

Today, We want to share with you Simple Vue 2.0 Select All Checkbox.In this post we will show you vue uncheck all checkboxes, hear for How to Select VueJs Check All Uncheck All Checkboxes we will give you demo and example for implement.In this post, we will learn about how to check checkbox is checked or not in vue js with an example.

Simple Vue 2.0 Select All Checkbox

There are the Following The simple About Simple Vue 2.0 Select All Checkbox Full Information With Example and source code.

As I will cover this Post with live Working example to develop [Vue 2.0] checkbox within custom component, so the how to select vuejs check all uncheck all checkboxes for this example is following below.

Step 1: HTML Part

index.html

<script src="https://cdn.jsdelivr.net/vue/latest/vue.js"></script>

<div id="app">
    <h4>Product</h4>
        <div>
            <table>
                <tr>
                    <th>Name</th>
                    <th>Select All<input type="checkbox" @click="selectAll" v-model="allSelected"></th>
                </tr>
                <tr v-for="product in products">
                    <td>{{ product.name }}</td>
                    <td><input type="checkbox" v-model="productIds" @click="select" :value="product.id"></td>
                </tr>
            </table>
        </div>

        <span>Selected Ids: {{ productIds }}</span>
</div>

Step 2: JavaScript Part

index.js

new Vue({
    el: '#app',
    data: {
        products: [ 
            { "id": "001", "name": "Book" }, 
            { "id": "002", "name": "DVD" }, 
            { "id": "003", "name": "Iphone" }, 
            { "id": "004", "name": "Laptop" }, 
            { "id": "005", "name": "Mobile" }
        ],
        selected: [],
        allSelected: false,
        productIds: []
    },
    methods: {
        selectAll: function() {
            this.productIds = [];

            if (this.allSelected) {
                for (product in this.products) {
                    this.productIds.push(this.products[product].id.toString());
                }
            }
        },
        select: function() {
            this.allSelected = false;
        }
    }
})

Vue Js 2.x – Select All Checkbox
Web Programming Tutorials Example with Demo

Read :

  Form Input Bindings in vue.js

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Vuejs 2.0 Select All Checkbox.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Reply

avatar
  Subscribe  
Notify of