Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body ng-app="myModule">
  <div class="wrapper" ng-controller="myController"></div>
</body>
</html>
 
angular.module('myModule', [])
.controller('myController', ['$q', '$timeout', function($q, $timeout){
  var promise = $q(function(resolve){
    console.log('function runs');
    $timeout(function(){
      resolve('a');
    }, 2000);
  });
  
  promise.then(function(data){
    console.log('then function runs');
    console.log(data);
  });
}]);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x