How to add the object values into table using angularjs -
var app = angular.module("myapp", ["ngsanitize"]); app.controller("controller", ['$scope', function($scope) { $scope.tasks = [{ item: "shopping", status: true }, { item: "cleaning", status: false }]; }]);
and html
<div ng-app="myapp"> <div ng-controller='controller'> <table border=1 ng-repeat='task in tasks'> <tr> <td>{{task.item}}</td> <td>{{task.status}}</td> </tr> </table> </div> </div>
i tried above not able attach header table.and @ place of done tring attach checkbox...i mean if status true chexk box must checked or else unchecked.
output: item done shopping checkbox ticked cleaning checkbox without ticked
see documentation checkbox input
not answer, why repeat table instead of rows?
<div ng-app="myapp"> <div ng-controller='controller'> <table border=1 > <tr> <th>name</th> <th>status</th> </tr> <tr ng-repeat='task in tasks'> <td>{{task.item}}</td> <td><input type="checkbox" ng-model="task.status"></td> </tr> </table> </div> </div>
but don't see sense in table in case.
<span ng-repeat="task in tasks"> <input type="checkbox" ng-model="task.status"> {{task.item}} </span>
that cleaner.
Comments
Post a Comment