5th practical aad code and output
<!DOCTYPE html>
<html ng-app="studentApp">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="Scripts/angular.js"></script>
</head>
<body class="container" ng-controller="studentController">
Status: {{status}} <br />
Data: {{data}} <br />
<input type="button" value="Get Data" ng-click="getStudent()" />
<script>
var app = angular.module('studentApp', []);
app.config(function ($provide) {
$provide.decorator('$exceptionHandler', function ($delegate) {
return function (exception, cause) {
$delegate(exception, cause);
alert('Error occurred! Please contact admin.');
};
});
});
app.controller("studentController", function ($scope, $http) {
var onSuccess = function (response) {
$scope.status = response.status;
$scope.data = response.data;
};
var onError = function (response) {
$scope.status = response.status;
$scope.data = response.data;
};
$scope.getStudent = function () {
$http.get("/getdata").then(onSuccess, onError);
};
});
</script>
</body>
</html>
No comments