AngularJS - Error: $injector:unpr Unknown provider: $soapProvider

AngularJS - Error: $injector:unpr Unknown provider: $soapProvider

我正在尝试根据此页面 http://mcgivery.com/soap-web-services-angular-ionic/

在 AngularJS 中使用 SOAP 服务进行简单的服务调用

但我收到此错误:错误:[$injector:unpr] http://errors.angularjs.org/1.4.3/$injector/unpr?p0=%24soapProvider%20%3C-%20%24soap%20%3C- %20呼叫服务

这是我的代码:

index.html

<!doctype html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <script src="angular.min.js"></script>
    <script src="soapclient.js"></script>
    <script src="angular.soap.js"></script>
</head>
<body>
<form method="post" action="">
    <div ng-app="myApp" ng-controller="MainCtrl">
        <div>
            <input type="button" value="Call Web Service - Test" ng-click="CallService();" />
        </div>
    </div>
</form>

<script src="app.js"></script>

</body>
</html>

app.js

var app = angular.module('myApp', [])

app.factory("CallService", ['$soap',function($soap){
    var base_url = "http://10.0.0.70:8080/WS_usrService/WS_usr?wsdl";

    return {
        getAll: function(){
            return $soap.post(base_url, "getAll");
        }
    }
}])

app.controller('MainCtrl', function($scope, CallService) {
    CallService.getAll().then(function(response){
        $scope.response = response;
    }, function(){
        console.log("Something went wrong!");
    });

})

谢谢

错误消息表明 Angular 无法找到在模块 angularSoap.

上定义的服务 $soap

根据official guide,添加模块依赖为:

var app = angular.module('myApp', ['angularSoap'])

在您的情况下,所有服务和控制器都在 "myApp" 中启动。

您在引导应用程序时没有定义 $soap 。

一定是这样的var app = angular.module('myApp', ['angularSoap'])