<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<title>Student list</title>
</head>
<body ng-app="myApp" ng-controller="studCtrl">
<form>
<div ng-controller="studCtrl">
<h3>List of students living in pune</h3><br>
<table border="2" bgcolor="Yellow">
<tr ng-repeat="x in stud | filter:'pune'">
<td>{{x.name}}</td>
<td>
{{x.city}}
</td>
</tr>
</table>
</div>
</div>
<input type="button" ng-click="showStudent()" value="Click Here"> </button>
</form>
<!--create a module-->
<script>
var app = angular.module("myApp", []);
app.controller('studCtrl', ['$scope', function ($scope) {
$scope.showStudent = function () {
$scope.stud = [
{ name: 'Azam', city: 'pune' },
{ name: 'Avinash', city: 'pune' },
{ name: 'Aavishkar', city: 'mumbai' },
{ name: 'Gaurav', city: 'mumbai' },
{ name: 'Saurabh', city: 'pune' },
];
}
}]);
</script>
</body>
</html>
0 Comments