多个依赖项不起作用

时间:2017-11-14 09:27:18

标签: angularjs dependencies ngroute

您好我正在尝试使用AngularJS创建SPA并需要调用SOAP请求。但是只要在ngRoute旁边添加另一个依赖项,我的视图就不会再加载了。

Index.html

    <!DOCTYPE html>
    <html class="no-js">
        <head>
            <script src="./angular/soapclient.js"></script>
            <script src="./angular/angular.soap.js"></script>
            <script src="./angular/angular.min.js"></script>
            <script src="./angular/angular-route.min.js"></script>
            <script src="./angular/app.js"></script>
        </head>
        <body data-t-name="ContentPage" ng-app="myApp">
            <div class="page">
                <div class="page-content">
                    <div class="container" id="Dialog1" >
                        <div ng-view ng-controller="MainCtrl"></div>
                    </div>
                </div>
            </div>
        </body>
    </html>

app.js

    var myApp = angular.module("myApp", ['ngRoute']);

    myApp.config(["$routeProvider","$locationProvider",function($routeProvider,$locationProvider) {
        $routeProvider
        .when("/", {
            templateUrl : "views/Hauptseite.html"
        })
        ...
        ...
    }]);

已更改为

var myApp = angular.module("myApp", ['ngRoute','angularSoap']);

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

更改依赖关系的顺序,任何依赖库应该在angular.js引用之后

<script src="./angular/angular.min.js"></script>
<script src="./angular/soapclient.js"></script>
<script src="./angular/angular.soap.js"></script>           
<script src="./angular/angular-route.min.js"></script>
<script src="./angular/app.js"></script>