Pattern for returning data from Angular AJAX calls

邮差的信 提交于 2019-12-08 18:11:22

That's the deferred anti-pattern, which practically warps a promise when not needed.

in your case returning a q.promise seems like an abuse since the HTTP object can return a promise itself.

I'd refactor the code to the following:

fetchEmployeeList: function() {
    return $http.get('/Employee/');
}

you can take a look to this blog post for more reference as well,

don't be afraid to open a discussion with whoever is suggesting that approach.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!