Translate

Thursday, 17 December 2015

How to Bind Table Using Angular JS

Bind Table Using Angular JS

View:


<div ng-app="repeatTable" ng-controller="practiece1" id="App4">
        <table >
            <tr >
                <td>Id</td>
                <td>User Name</td>
                <td>First Name</td>
                 <td>Last Name</td>
                 <td>Location</td>
            </tr>
            <tr ng-repeat="data in tabledata" style="border: solid">
                <td>{{data.Id}}</td>
                <td>{{data.UserName}}</td>
                <td>{{data.FirstName}}</td>
                 <td>{{data.LastName}}</td>
                 <td>{{data.Location}}</td>
            </tr>
        </table>

    </div>

<script>
  var aps = angular.module('repeatTable', []).controller('practiece1', function ($scope, $http) {
            alert("");
            $http.get('/AngularJS/TableData').success(function (data) {
                alert(data);
                $scope.tabledata = data;
            });

        });
</script>


In Controller:

    public ActionResult TableData()
        {
            var text = context.UserInfoes.ToList();
            return Json(text,JsonRequestBehavior.AllowGet);
        }


No comments:

Post a Comment