AngularJs: Have method return synchronously when it calls $http or $resource internally

后端 未结 5 1846
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 05:48

Is there a way to wait on a promise so that you can get the actual result from it and return that instead of returning the promise itself? I\'m thinking of something simila

5条回答
  •  自闭症患者
    2020-12-29 06:26

    You can't - there aren't any features in angular, Q (promises) or javascript (at this point in time) that let do that.

    You will when ES7 happens (with await).

    You can if you use another framework or a transpiler (as suggested in the article linked - Traceur transpiler or Spawn).

    You can if you roll your own implementation!

提交回复
热议问题