Example: Consume Rest API using Angular 1: Pretty Simple Code #AngularJS

Angular – Module


 

angular.module('demo', [])
.controller('Hello', function($scope, $http) {
    $http.get('http://rest-service.guides.spring.io/greeting').
        then(function(response) {
            $scope.greeting = response.data;
        });
});

HTML file to Show Output i.e. data as retrieved from REST call

<!doctype html>
<html ng-app=”demo”>
<head>
<title>Hello AngularJS</title>
https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js
http://hello.js
</head>

<body>
<div ng-controller=”Hello”>
<p>The ID is {{greeting.id}}</p>
<p>The content is {{greeting.content}}</p>
</div>
</body>
</html>

  From: http://sitestree.com/?p=10903
Categories:AngularJS
Tags:
Post Data:2017-07-28 21:10:11

Shop Online: https://www.ShopForSoul.com/
(Big Data, Cloud, Security, Machine Learning): Courses: http://Training.SitesTree.com
In Bengali: http://Bangla.SaLearningSchool.com
http://SitesTree.com
8112223 Canada Inc./JustEtc: http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning)
Shop Online: https://www.ShopForSoul.com/
Medium: https://medium.com/@SayedAhmedCanada