$element 中的控制台错误,同时使用 AngularJS Material 的 $mdDialog

Console Error in $element, while using $mdDialog of AngularJS Material

我正在尝试解决控制台中显示的这个错误,它只发生在服务器上,在我的本地主机中,模式正常工作。这是错误(单击以打开其 link):

我对控制器有看法:

.when('/aseguradora', {
    templateUrl: 'views/insuranceagentdashboard.html',
    controller: 'InsuranceagentdashboardCtrl'
})

这是控制器:

angular.module('virtualApp').controller('InsuranceagentdashboardCtrl', ['$http', '$scope', 'pager', 'Dialogs', function($http, $scope, pager, Dialogs) {..

在控制器内部,我有一个执行模态的函数,(对话框是一项服务):

$scope.showCosignerFormDialog = function(insuranceRequest) {
    Dialogs.cosignerFormdialog(insuranceRequest);
}

在 HTML 我有一个 md-buttonng-click

<md-button class="md-color-green" ng-click="showCosignerFormDialog(insuranceRequest)">VER SOLICITUD</md-button>

这是执行模态的Dialog服务:

dialogs.cosignerFormdialog = function(insuranceRequest) {
    return $mdDialog.show({
        templateUrl: 'views/cosignerformdialog.html',
        autoWrap: false,
        controller: 'IdentityVerificationWizardCtrl',
        locals: {
            listing: insuranceRequest
        },
        preserveScope: true,            
        escapeToClose: false,
        fullscreen: true,
        clickOutsideToClose: true
    });
};

我不知道为什么在服务器 URL 中的控制台中会出现此错误,如果我在本地主机中,则不会出现此错误...

这是控制器 identityverificationwizard.js:

angular.module('virtualApp').controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', '$element', function($scope, upload, $http, listing, $routeParams, $location, Dialogs, $element) {
    $scope.propertyListing = listing;
    $scope.insuranceStudyContactInfo = {};
    $scope.insuranceStudyJobInfo = {};
    $scope.insuranceStudyFinancialInfo = {};
    $scope.insuranceStudyAssets = {};
    $scope.identityInfo = {
        date : moment('01/01/2000', 'DD/MM/YYYY').toDate()
    };
    $scope.virtualSignatureInfo = {};
    $scope.isCorporation = 'false';
    $scope.insuranceStudyJobInfo.publicOfficer = false;
    $scope.insuranceStudyJobInfo.managesPublicFunds = false;
    $scope.insuranceStudyJobInfo.linkedToRenownedPeople = false;
    $scope.insuranceStudyJobInfo.vatResponsible = false;
    $scope.insuranceStudyJobInfo.greatContributor = false;

    $scope.insuranceStudyFinancialInfo.doImport = false;
    $scope.insuranceStudyFinancialInfo.doExport = false;
    $scope.insuranceStudyFinancialInfo.doInvest = false;
    $scope.insuranceStudyFinancialInfo.doCurrencyExchange = false;
    $scope.insuranceStudyFinancialInfo.doPayServices = false;
    $scope.insuranceStudyFinancialInfo.doPayLoans = false;
    $scope.insuranceStudyFinancialInfo.doTransactions = false;

    $scope.rentProcessId = $scope.propertyListing.rentProcessId;
    $scope.cosignerKey = $location.search().cosignerKey;

    if ($scope.rentProcessId || $scope.cosignerKey) {
        $scope.readOnly = false;
    } else {
        $scope.readOnly = true;
    }

    $scope.setTabIndex = function(index) {
        $scope.tabIndex = index;
    }

    $scope.fileChanged = function(kind, file) {

        var reader = new FileReader();
        reader.onload = function(e) {
            if (kind == 'front') {
                $scope.frontIdFile = file;
                $scope.frontIdImage = e.target.result;
                $scope.$apply();
            } else {
                $scope.backIdFile = file;
                $scope.backIdImage = e.target.result;
                $scope.$apply();
            }
        };
        reader.readAsDataURL(file.files[0]);
        $scope.$apply();
    }

    $scope.uploadForm = function() {
        var params = {};

        if ($scope.insuranceStudyContactInfo.city) {
            $scope.insuranceStudyContactInfo.cityCode = $scope.insuranceStudyContactInfo.city.cityCode;
        }

        if ($scope.insuranceStudyJobInfo.city) {
            $scope.insuranceStudyJobInfo.cityCode = $scope.insuranceStudyJobInfo.city.cityCode;
        }
        if ($scope.insuranceStudyAssets.hasProperties) {
            if ($scope.insuranceStudyAssets.property1 && $scope.insuranceStudyAssets.property1.city) {
                $scope.insuranceStudyAssets.property1.cityCode = $scope.insuranceStudyAssets.property1.city.cityCode || null;
            } else {
                delete $scope.insuranceStudyAssets.property1;
            }

            if ($scope.insuranceStudyAssets.property2 && $scope.insuranceStudyAssets.property2.city) {
                $scope.insuranceStudyAssets.property2.cityCode = $scope.insuranceStudyAssets.property2.city.cityCode || null;
            } else {
                delete $scope.insuranceStudyAssets.property2;
            }
        } else {
            delete $scope.insuranceStudyAssets.property1;
            delete $scope.insuranceStudyAssets.property2;
        }

        if ($scope.propertyListing.rentProcessId) {
            params.rentProcessId = $scope.propertyListing.rentProcessId;
        }

        if ($location.search().cosignerKey) {
            params.cosignerKey = $location.search().cosignerKey;
        }

        if ($scope.identityInfo.date) {
            $scope.identityInfo.birthDate = formatedDate($scope.identityInfo.date, 'DD/MM/YYYY');
        }
        $scope.insuranceStudyFinancialInfo.doImport = $scope.insuranceStudyFinancialInfo.doImport || false;
        $scope.insuranceStudyFinancialInfo.doExport = $scope.insuranceStudyFinancialInfo.doExport || false;
        $scope.insuranceStudyFinancialInfo.doInvest = $scope.insuranceStudyFinancialInfo.doInvest || false;
        $scope.insuranceStudyFinancialInfo.doCurrencyExchange = $scope.insuranceStudyFinancialInfo.doCurrencyExchange || false;
        $scope.insuranceStudyFinancialInfo.doPayServices = $scope.insuranceStudyFinancialInfo.doPayServices || false;
        $scope.insuranceStudyFinancialInfo.doPayLoans = $scope.insuranceStudyFinancialInfo.doPayLoans || false;
        $scope.insuranceStudyFinancialInfo.doTransactions = $scope.insuranceStudyFinancialInfo.doTransactions || false;

        params.isCorporation = $scope.isCorporation;
        params.contactInfo = JSON.stringify($scope.insuranceStudyContactInfo);
        params.jobInfo = JSON.stringify($scope.insuranceStudyJobInfo);
        params.financialInfo = JSON.stringify($scope.insuranceStudyFinancialInfo);
        params.assets = JSON.stringify($scope.insuranceStudyAssets);
        params.virtualSignatureInfo = JSON.stringify($scope.virtualSignatureInfo);
        params.identityInfo = JSON.stringify($scope.identityInfo);

    $scope.isReadOnly = function() {
        if ($scope.readOnly) {
            $http.get(root + "Insurance/s/getInsuranceRequest", {
                params: {
                    insuranceRequestId: $scope.propertyListing.insuranceRequestId
                }
            }).then(function(res) {
                $scope.code = res.data.code;
                $scope.type = res.data.type;
                $scope.datetime = res.data.datetime;
                $scope.status = res.data.status;
                $scope.listingCode = res.data.listingCode;
                $scope.isCorporation = res.data.corporation + "";
                $scope.identityInfo.documentTypeCode = res.data.identityInfo.documentTypeCode;
                $scope.identityInfo.documentNumber = res.data.identityInfo.documentNumber;
                $scope.identityInfo.names = res.data.identityInfo.names;
                $scope.identityInfo.lastNames = res.data.identityInfo.lastNames;
                $scope.identityInfo.date = res.data.identityInfo.birthDate;
                $scope.insuranceStudyContactInfo = res.data.contactInfo;
                $scope.insuranceStudyJobInfo = res.data.jobInfo;
                $scope.insuranceStudyFinancialInfo = res.data.financialInfo;

                if ($scope.insuranceStudyFinancialInfo.foreignAccountBank) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccount) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCurrency) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCountry) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.foreignAccountCity) {
                    $scope.insuranceStudyFinancialInfo.doForeignAccount = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doImport) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doExport) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doInvest) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doCurrencyExchange) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doPayServices) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doPayLoans) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }
                if ($scope.insuranceStudyFinancialInfo.doTransactions) {
                    $scope.insuranceStudyFinancialInfo.doInternationalOperations = true;
                }


                $scope.insuranceStudyAssets = res.data.assets;

                if ($scope.insuranceStudyAssets.property1 || $scope.insuranceStudyAssets.property2) {
                    $scope.insuranceStudyAssets.hasProperties = true;
                }

                if ($scope.insuranceStudyAssets.vehicle1 || $scope.insuranceStudyAssets.vehicle2) {
                    $scope.insuranceStudyAssets.hasCars = true;
                }

                $scope.availableActions = res.data.availableActions;
            });
        }
    }
    $scope.isReadOnly();
}]);

该错误表明您在控制器中使用了未知依赖项。 此处,错误表明“unknown dependency”是一个名为 $element.

的提供程序

! angularjs 中有 3 种类型的提供者:服务、工厂或提供者

您遇到此问题的 2 个原因:

1) 如果您的项目中没有任何名为 $element 的提供者(服务、工厂或提供者),您不应该依赖它。 在 IdentityVerificationWizardCtrl

而不是:

.controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', '$element', function($scope, upload, $http, listing, $routeParams, $location, Dialogs, $element)

写入:

.controller('IdentityVerificationWizardCtrl', ['$scope', 'upload', '$http', 'listing', '$routeParams', '$location', 'Dialogs', function($scope, upload, $http, listing, $routeParams, $location, Dialog)

2) 如果您有一个名为 $element 的提供商,也许您没有将其调用到您的 index.html

PS:在angularjs中,$element是link函数中使用的参数,指的是DOM元素。所以 IMO 认为你的错误是因为原因 1