$http Post Method With And Withour parameter
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.17/angular.min.js"></script>
<script>
var mainApp = angular.module("mainApp", []);
mainApp.controller('tripController', function ($scope, $http) {
var parameter = JSON.stringify('{ClientId:130}');
$http({
method: 'POST',
data: { ClientId: "130" },
url: 'http://localhost/msr/ContactService.svc/GetContact'
})
.success(function (data) {
$scope.contacts = data;
});
});
mainApp.controller('TimeZoneController', function ($scope, $http) {
alert("In");
$http({
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
url: 'http://localhost/msr/Common.svc/GetTimeZone'
})
.success(function (data) {
$scope.timezones = data;
});
});
</script>
</head>
<body>
<h2>AngularJS Sample Application</h2>
<div ng-app="mainApp">
<div ng-controller="tripController">
<table>
<tr>
<td>ClientId</td>
<td>ContactId</td>
<td>Names</td>
<td>Email</td>
</tr>
<tr ng-repeat="contact in contacts.lstContact">
<td>{{ contact.ClientId }}</td>
<td>{{ contact.ContactId }}</td>
<td>{{ contact.Name}}</td>
<td>{{ contact.EmailOrMobile }}</td>
</tr>
</table>
</div>
<h2>Time Zone</h2>
<div ng-controller="TimeZoneController">
<table>
<tr>
<td>Text</td>
<td>Value</td>
</tr>
<tr ng-repeat="timezone in timezones.GetTimeZoneResult.lstTimezone">
<td> {{ timezone.Text }} </td>
<td> {{ timezone.Value }} </td>
</tr>
</table>
</div>
</div>
</body>
</html>
No comments:
Post a Comment