AngularJS promise returning empty object
问题 Basically what I want to do, is to assign some model value from function call that resolves promise. Like so value = someFun() This is a service from which I call this function app.factory('SomeService', function($q) { return { someFun: function() { var d = $q.defer(); try { d.resolve("hi"); } catch (e) { d.reject(e); } return d.promise.then(function(text){ return text; }); } }; }); Here is the HTML code <div ng-init="value = 'yes'"> <pre>{{value |json}}</pre> </div> <button type="button" ng