Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="DetailController as vm">
</body>
</html>
 
angular.module('myApp',[]);
angular.module('myApp').factory('otherService', function() {
  var doTheThing;
  doTheThing = function() {
    return console.log('did the thing!');
  };
  return {
    doTheThing: doTheThing
  };
});
angular.module('myApp').controller('DetailController', function($rootScope, $scope, otherService, $q) {
  var getData, onStart;
  onStart = function() {
    getData();
  };
  getData = function() {
  
    console.log(otherService);
    console.log($q);
    return $q.when(true).then(function(result) {
      $scope.data = result.data;
      return otherService.doTheThing();
    });
  };
  return onStart();
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers