Any way to know if a variable is an angularjs promise?

后端 未结 4 1578
情书的邮戳
情书的邮戳 2020-12-14 14:33

I\'m making a directive that takes a function as a scope parameter (scope: { method:\'&theFunction\' }). I need to know if the result returned by that metho

4条回答
  •  不思量自难忘°
    2020-12-14 15:09

    You can use $q.when to wrap the object as a promise (whether it is or not). Then, you can be sure that you are always dealing with a promise. This should simplify the code that then handles the result.

    Documentation for $q.when is here with $q.

提交回复
热议问题