TypeError: Cannot read property 'post' of undefined and $resource is undefined in second post request
TypeError: Cannot read property 'post' of undefined and $resource is undefined in second post request
$resource 在 angular 服务的第一次调用中定义。但是当它第二次调用时,它给出了以下错误;
TypeError: Cannot read property 'post' of undefined
在调用 .post 之前检查 $resource。它 returns undefined,这意味着 $resource 在第二次使用之前变得未定义。
这会是什么原因造成的?以及解决此问题的任何提示。
这可能是因为您定义的 $resource 被覆盖了。已通过仅在未定义时定义 $resouce 来解决此问题。
if(angular.isUndefined(资源))
//定义你的资源
$resource 在 angular 服务的第一次调用中定义。但是当它第二次调用时,它给出了以下错误;
TypeError: Cannot read property 'post' of undefined
在调用 .post 之前检查 $resource。它 returns undefined,这意味着 $resource 在第二次使用之前变得未定义。
这会是什么原因造成的?以及解决此问题的任何提示。
这可能是因为您定义的 $resource 被覆盖了。已通过仅在未定义时定义 $resouce 来解决此问题。
if(angular.isUndefined(资源)) //定义你的资源