我正在尝试学习AngularJs,并且正在观看课程,下面的图像中显示了此代码。作者正在做$http.get("url").then(function()...
。我不理解的是onUserComplete
函数接受response
参数,但是在then
函数中,他没有传递此response
参数,因此该示例有效。据我在JavaScript中了解到的,我们应该这样做:then(onUserComplete(response)) ;
有人可以向我解释吗?
最佳答案
.then()
函数采用回调函数作为其参数。回调函数存储在变量onUserComplete
中。因此,当作者编写.then(onUserComplete)
时,并未调用onUserComplete
,它只是作为参考传递。