Click here to Skip to main content
15,897,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
how to assign cell id as row number + col number of a dynamic html table using angularjs and javascript

What I have tried:

how to assign cell id as row number + col number of a dynamic html table using angularjs and javascript
Posted
Updated 31-Jul-16 21:34pm
v2

1 solution

try this

HTML
<!DOCTYPE html>
<html lang="en-US">
<head>
    
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    <script>
        var app = angular.module('myapp', []);
        app.controller('myctrl', myctrl);

        var data = [{ id: 1, name: 'aa' }, { id: 2, name: 'bb' }, { id: 3, name: 'cc' }, { id: 4, name: 'dd' }]
        function myctrl($scope) {
            $scope.mydata = data;
        }
    </script>
</head>
<body>
    <div ng-app="myapp" ng-controller="myctrl">
        <table>
            <tr>
                <td>ID</td><td>Name</td>
            </tr>
            <tr ng-repeat="row in mydata">
                <td id="{{$index}}1">{{row.id}}</td>
                <td id="{{$index}}2">{{row.name}}</td>
            </tr>
        </table>
    </div>
</body>
</html>
 
Share this answer
 
Comments
Karthik_Mahalingam 31-Jul-16 6:02am    
then you will have to rebind the data after delete

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900