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

时间:2018-01-26 21:32:35

标签: javascript angularjs angularjs-material mddialog

我正在尝试解决在控制台中显示的此错误,它只发生在服务器上,在我的localhost中,模式正常工作。这是错误(点击打开它的链接):

我有控制器的视图:

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

这是控制器:

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

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

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

在HTML中,我有md-button ng-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中的控制台中会出现此错误,如果我在我的localhost中我没有收到此错误...

这是控制器 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();
}]);

1 个答案:

答案 0 :(得分:2)

该错误表明您在控制器中使用未知依赖。 在这里,错误表明&#34; 未知依赖&#34;是一个名为 $ element 的提供商。

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

有两个原因导致您遇到此问题:

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是用于链接函数的参数,并引用DOM元素。所以IMO认为你的错误是因为原因1