Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/384.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS模块上的括号使我的网页空白_Javascript_Html_Angularjs - Fatal编程技术网

Javascript AngularJS模块上的括号使我的网页空白

Javascript AngularJS模块上的括号使我的网页空白,javascript,html,angularjs,Javascript,Html,Angularjs,我有这段代码 (function() { 'use strict'; var app = angular.module('e2EApp'); app.controller('SearchController', SearchController); SearchController.$inject = ['$scope','$state', '$http']; function SearchController ($scope, $state, $http) { var

我有这段代码

(function() {
'use strict';

var app = angular.module('e2EApp');
    app.controller('SearchController', SearchController);

SearchController.$inject = ['$scope','$state', '$http'];


function SearchController ($scope, $state, $http) {
    var vm = this;

    vm.doSearch = function() {
        $http({
            method: 'GET',
            url: "http://localhost:8080/api/search/" + vm.search.searchTerm + "/" + vm.search.sortTerm
        }).then(function successCallback(response) {
            if (response.status == 200) {
                vm.search.users = response.data
            }
        });
    };

}})();
当我把括号放在angular.module里面时,就像这样

angular.module('e2EApp', []);
保存文件并刷新页面后,模块名为“e2Epp”的网页为空。当我移除它们时,它们又能正常工作了。我想在括号内添加'ngSanitize',但即使我不这样做,并将其留空,问题仍然存在。有什么线索吗

传递一个参数将检索现有的
angular.Module
,而传递多个参数将创建一个新的
angular.Module

在您的代码段中,
angular.module('e2EApp')
将检索现有模块定义,以便您可以使用其他定义(例如
SearchController
)对其进行扩充。另一方面,
angular.module('e2EApp',[])
定义了一个没有AngularJS模块依赖关系的新模块

我猜您已经在其他地方定义了
e2EApp

如果要添加
ngSanitize
依赖项,请将其添加到原始模块定义中


非常感谢。这正是问题所在,尽管我在正确使用消毒液时遇到了问题。现在我的网页又打开了,但“清理”似乎不起作用。我有一个库的cdn路径的源代码。没问题。您还没有提到您是否正在使用JS绑定器。如果您只是通过
script
标记包含AngularJS依赖项,那么可以检查
angular sanitize.js
是否包含在
angular.js
之后。谢谢miqid。多亏了你,我终于解决了所有的问题。非常感谢!