angular pass data to a html tag elemet code example

Example 1: pass dynamic javascript value to html

function myFunction(no) {
    if (document.getElementById("showHide"+no).style.display=="none")
    {
      document.getElementById("showHide"+no).style.display="block";
    }
    else
    {
      document.getElementById("showHide"+no).style.display="none";
    }
}

Example 2: vuejs get data fromo ajax

<script type="text/javascript">
var ItemsVue = new Vue({
    el: '#Itemlist',
    data: {
        items: []
    },
    mounted: function () {
        var self = this;
        $.ajax({
            url: '/items',
            method: 'GET',
            success: function (data) {
                self.items = JSON.parse(data);
            },
            error: function (error) {
                console.log(error);
            }
        });
    }
});
</script>

<div id="Itemlist">
    <table class="table">
        <tr>
            <th>Item</th>
            <th>Year</th>
        </tr>
        <tr v-for="item in items">
            <td>{{item.DisplayName}}</td>
            <td>{{item.Year}}</td>
        </tr>
    </table>
</div>

Tags:

Php Example