$ scope在服务AngularJs中未定义:

斯瓦米·雷迪(Swamy Reddy)

当我用于响应消息时出现未定义范围的错误:

$scope.responsemessage = response;

然后我在这里添加$ scope像这样:

app.service('fileUpload', ['$http', '$scope', function ($http, $scope) {

当我在$ scope上面添加时,出现此错误错误:[$ injector:unpr] http://errors.angularjs.org/1.4.8/ $ injector / unpr?p0 = ............ .....

阿尼克伊斯兰教阿比

服务没有范围。

如果您想在服务内部使用范围,则必须从控制器传递它。

像这样

在控制器中

fileUpload.checkFile($scope.responsemessage);

服役中

function checkFile(respMsg)
{
   console.log(respMsg);
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章