AngularJS 卡在模块中

AngularJS stuck in module

提问人:user199135 提问时间:12/1/2021 最后编辑:paulsm4user199135 更新时间:12/8/2021 访问量:32

问:

app.controller('TableContent', ['$http', '$scope', '$window',

    function ($scope, $window) {
        console.log("I'm in TableContent");
        $scope.EditSaverCommit = function () {
            console.log("I'm in EditSaverCommit");
            EditIndex = $scope.$index;
            EditProjectID = $scope.project.ID;
            console.log("Scope has"+$scope.project.Name);
            EditProject = $scope.project.Name;
            console.log("EditProject has "+EditProject);
        };

        $scope.DeleteProjectCommit = function () {
            console.log("I'm in DeleteProjectCommit");
            $window.Project.splice($scope.$index, 1);
            ProjectLength = Project.length;
            PostData = "";
            $scope.Project = $window.Project;

            PostData = $scope.Project.ID;
            $http.get("https://localhost:44377/project/DeleteProject/"+PostData).then(function (response) {
                console.log("I'm in DeleteProject");
                $window.Project = response.data;
            });
            PostData = "";
            console.log("I'm not in TableContent");
        };
    }]);

大家好,在加载我的页面时,我遇到了这个片段的问题。 加载整个页面后,自从我修改此部分以接受 http.get 以来,我的所有其他 http.get 请求都已关闭。 它在完全加载后不会打印“我不在 TableContent 中”,所有其他 http.get 请求都处于瘫痪状态,但会打印它们各自的控制台.log() 消息。

AngularJS的

评论


答:

2赞 Nechoj 12/1/2021 #1

缺少参数作为函数参数:$http

app.controller('TableContent', ['$http', '$scope', '$window',
  function ($http, $scope, $window) {
    ...
  };
}]);

这破解了依赖注入...