0

I am picking up checkbox Data from Controller file, but it is not rendering properly. Following is my html:

HTML:

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<table>
    <tr ng-repeat="x in People">
        <input type="checkbox" id="{{x.id}}" >{{x.name}}<br/> 
    </tr>
</table>
<button>Click</button>
<script>
//Module Declaration
var app = angular.module('myApp',[]);
//Controller Declaration
app.controller('myCtrl',function($scope){
    $scope.People = [
        {name:"Peter",id:"201"},
        {name:"Lina",id:"202"},
        {name:"Roger",id:"203"}
    ];
});
</script>
</body> 
</html>

Expectation:

3 rows of input checkboxes with names adjescent to them

Result:

enter image description here

There are no JS Errors. Can someone help me out what is wrong in this?

1 Answer 1

5

Just add a "td" tag : JSFIDDLE

<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body ng-app="myApp" ng-controller="myCtrl">
<table>
    <tr ng-repeat="x in People">
      <td>
        <input type="checkbox" id="{{x.id}}" >{{x.name}}<br/> 
      </td>
    </tr>
</table>
<button>Click</button>
<script>
//Module Declaration
var app = angular.module('myApp',[]);
//Controller Declaration
app.controller('myCtrl',function($scope){
    $scope.People = [
        {name:"Peter",id:"201"},
        {name:"Lina",id:"202"},
        {name:"Roger",id:"203"}
    ];
});
</script>
</body> 
</html>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.