Introduction
Hi all, I hope you are fine. Today we will learn about AngularJS Basic Filters. If you are new to AngularJS then I suggest you read the Basics of AngularJS.
Now with the assumption that you have read my previous article, we are starting.
This article explains $http in Angular JS.
Using the code
$http is a service for reading data from web services. It uses the get (service URL) method for the process. We will see that with an example.
- <div ng-app="httpApp" ng-controller="httpController">
- <ul>
- <li ng-repeat="det in details">{{ det.name + ', ' + det.countrycode }}
- </li>
- </ul>
- </div>
- < script >
- var app = angular.module('httpApp', []);
- app.controller('httpController', function($scope, $http) {
- $http.get("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=- 22.4&west=55.2&lang=de&username=demo")
- .success(function(response) {
- $scope.details = response.geonames;
- });
- }); < /script>
So in the success part we are returning the response of the web service.
Now if you write the response.geonames in the success in the browser console as follows, you will get the array as shown below.
- console.log(response.geonames);

Once it is returned we are showing the response data to the UI using the repeat directive.
So that is all.
Complete HTML
- <!DOCTYPE html>
- <html
- xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Angular $http - SibeeshPassion </title>
- <style>
- li {
- border: 1px solid #ccc;
- border-right: none;
- border-left: none;
- padding: 2px;
- text-align: center;
- list-style:none;
- }
- </style>
- <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
- </head>
- <body>
- <div ng-app="httpApp" ng-controller="httpController">
- <ul>
- <li ng-repeat="det in details">{{ det.name + ', ' + det.countrycode }} </li>
- </ul>
- </div>
- <script>
- var app = angular.module('httpApp', []);
- app.controller('httpController', function ($scope, $http) {
- $http.get("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=sibeeshvenu")
- .success(function (response) {
- $scope.details = response.geonames;
- console.log(response.geonames);
- });
- });
- </script>
- </body>
- </html>

Now apply the CSS
Add the following CSS to your page.
- < style > li {
- border: 1px solid#ccc;
- border - right: none;
- border - left: none;
- padding: 2px;
- text - align: center;
- list - style: none;
- } < /style>

Cool. We did it.
Conclusion
Now that is all for the day, I will return with another set of items in Angular JS soon. I hope you liked this article. Please provide your valuable suggestions.
Kindest Regards,
Sibeesh venu
Sibeesh Passion


Sibeesh VenuTOP 100Posted May 3, 2015, 6:18 AM EDT
KP Singh Chundawat Thank you buddy
Karthik Muthu KaruppanPosted Apr 23, 2015, 7:30 AM EDT
Good one
Sibeesh VenuTOP 100Posted Apr 21, 2015, 2:56 AM EDT
Jitendra Kumar Thanks buddy
Jitendra KumarPosted Apr 21, 2015, 1:32 AM EDT
Nice one.
Sibeesh VenuTOP 100Posted Apr 18, 2015, 12:55 AM EDT
Nitin Tyagi Thanks dude.
Sibeesh VenuTOP 100Posted Apr 18, 2015, 12:55 AM EDT
KP Singh Chundawat Thank you buddy.
Sibeesh VenuTOP 100Posted Apr 18, 2015, 12:55 AM EDT
Santhakumar Munuswamy Thank you .
NitinPosted Apr 17, 2015, 8:56 PM EDT
good show
K P Singh ChundawatPosted Apr 17, 2015, 8:05 PM EDT
Nice Sibeesh...Keep it up
Santhakumar MunuswamyPosted Apr 17, 2015, 6:30 PM EDT
Good