got error of scope not defined when i use for response message:
$scope.responsemessage = response;
then I added $scope here like this:
app.service('fileUpload', ['$http', '$scope', function ($http, $scope) {
When I added above $scope got this error Error: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=.................
最佳答案
服务没有范围。
如果你想在服务中使用作用域,必须从 Controller 传递它。
像这样
在 Controller 中
fileUpload.checkFile($scope.responsemessage);
服务中
function checkFile(respMsg)
{
console.log(respMsg);
}
关于javascript - $scope 未在服务 AngularJs : 中定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35503984/