Peterson February 2016

checkBox ng-Repeat from controller-data not Rendering : AngularJs

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?

Answers


Zonedark February 2016

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>

Post Status

Asked in February 2016
Viewed 1,766 times
Voted 9
Answered 1 times

Search




Leave an answer