To repeat a series of elements instead of just one parent element, ngRepeat is used
<!DOCTYPE html>
<html ng-app="jj" ng-init="products=[{name:'Acer',category:'Laptop'},{name:'samsung',category:'phone'},{name:'fastrack',category:'watch'}]">
<head>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div ng-controller="prController">
<p>List of products</p><br>
<table border="1">
<tr>
<td>name</td>
<td>category</td>
</tr>
<tr ng-repeat="pr in products">
<td >{{pr.name}}</td>
<td >{{pr.category}}</td>
</tr>
</table>
</div>
<script>
angular.module("jj",[]).controller("prController",function($scope){
$scope.name;
$scope.category;
}
);
</script>
</body>
</html>
<!DOCTYPE html>
<html ng-app="jj" ng-init="products=[{name:'Acer',category:'Laptop'},{name:'samsung',category:'phone'},{name:'fastrack',category:'watch'}]">
<head>
<link rel="stylesheet" href="style.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body>
<div ng-controller="prController">
<p>List of products</p><br>
<table border="1">
<tr>
<td>name</td>
<td>category</td>
</tr>
<tr ng-repeat="pr in products">
<td >{{pr.name}}</td>
<td >{{pr.category}}</td>
</tr>
</table>
</div>
<script>
angular.module("jj",[]).controller("prController",function($scope){
$scope.name;
$scope.category;
}
);
</script>
</body>
</html>
No comments:
Post a Comment