Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
<html ng-app="yourApp">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var app = angular.module('yourApp',[]);
function GlobalServices(){
  this.baseUrl = 'test';
}
app.service('globalServices', GlobalServices)
function GetWidgetsService($http, globalServices){
    this._$http = $http;
    this._globalServices = globalServices;
}
GetWidgetsService.prototype.getData = function() {
      console.log('Called getData!');
    var getWidgetUrl = this._globalServices.baseUrl + "admin/widget/list-text-widget";
    // Angular $http() and then() both return promises themselves
    return this._$http({method:"GET", url:getWidgetUrl}).then(function(result){
        // What we return here is the data that will be accessible
        // to us after the promise resolves
        return result.data;
    });
};
app.service('getWidgetsService', GetWidgetsService);
app.run(function(getWidgetsService){
  getWidgetsService.getData();
});
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers