Advertisement
Guest User

angular

a guest
Aug 27th, 2014
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // html
  2. <button ng-click="hello">Click here</button>
  3.  
  4. <div>
  5.     <ng-repeat"name in users">
  6.         {{name}}
  7. </div>
  8.  
  9. //maincontroller.js
  10.  
  11. app.controller('mainController',function($scope,$http) {
  12.     $scope.users = {}
  13.  
  14.     $scope.hello = function() {
  15.         $http.get('http://localhost:3000/api/users')
  16.         .success(function(data) {
  17.             $scope.users = data;
  18.         }).catch(function(error) {
  19.             console.error(error);
  20.         });
  21.     }
  22. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement