<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.0/angular.min.js"></script>
<title> Employee list</title>
</head>
<body ng-app="myApp" ng-controller="empCtrl">
<form>
<div ng-controller="empCtrl">
List of employees order by salary<br>
<table border="2">
<tr ng-repeat="x in emp| orderBy:'salary'">
<td>{{x.name}}</td>
<td>
{{x.city}}
</td>
<td>{{x.salary}}</td>
</tr>
</table>
</div>
<br>
<br>
<br>
<br>
</div>
<input type="button" ng-click="showEmployee()" value="Click Here"> </button>
</form>
<script>
var app = angular.module("myApp", []);
app.controller('empCtrl', ['$scope', function ($scope) {
$scope.showEmployee = function () {
$scope.emp = [
{ name: 'Husen', city: 'pune',salary:'5000' },
{ name: 'Akashay', city: 'pune',salary:'9000' },
{ name: 'Yash', city: 'mumbai',salary:'7000' },
{ name: 'Kisan', city: 'mumbai',salary:'8000'},
];
}
}]);
</script>
</body>
</html>
0 Comments