Thursday, November 26, 2015

Setting data from web service

<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Example - example-example60-production</title>
 

  <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script>
 

 
</head>
<body ng-app="bindExample">
  <script>
  var app = angular.module('bindExample', []);
  app.controller('ExampleController', function($scope, $http) {
      $http.get("http://jsonplaceholder.typicode.com/posts/1")

    .success(function (response) {
       
        $scope.names = response;
        $scope.id=names.postId;
        $scope.title=names.title;

       
    }
   
    );
  });
</script>
<div ng-controller="ExampleController">
    <label>Id <input type="text" ng-model="names.id"></label><br>
        <label>Msg <input type="text" ng-model="names.title"></label><br>
   
    
 
 
</div>
</body>
</html>

No comments:

Post a Comment