How to make controller wait for promise to resolve from angular service
问题 I have a service that is making an AJAX request to the backend Service: function GetCompaniesService(options) { this.url = '/company'; this.Companies = undefined; this.CompaniesPromise = $http.get(this.url); } Controller: var CompaniesOb = new GetCompanies(); CompaniesOb.CompaniesPromise.then(function(data){ $scope.Companies = data; }); I want my service to handle the ".then" function instead of having to handle it in my controller, and I want to be able to have my controller act on that data