AngularJS Slip no 17 Solution

<html ng-app="studentApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
</head>
<body ng-controller="StudentController">
<h1>Search Student by Name</h1>
<label for="searchInput">Search Student:</label>
<input type="text" id="searchInput" ng-model="searchText">
<table>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
<tr ng-repeat="student in students | filter: searchText">
<td>{{ student.name }}</td>
<td>{{ student.age }}</td>
<td>{{ student.city }}</td>
</tr>
</table>
<script>
var app = angular.module('studentApp', []);
app.controller('StudentController', function ($scope) {
$scope.students = [
{ name: 'Anil', age: 20, city: 'Pune' },
{ name: 'Bharat', age: 22, city: 'Mumbai' },
{ name: 'Chetan', age: 21, city: 'Pune' },
{ name: 'Deepak', age: 19, city: 'Delhi' }
];
});

</script>
</body>
</html>

No comments:

Post a Comment