模态对话框解决忽略传递的属性值

时间:2018-07-30 15:39:22

标签: javascript angularjs modal-dialog bootstrap-modal

我正尝试转移一些模态属性

service.confirm = function(message, confirmProperties) {
        return $uibModal.open({
            templateUrl: 'app/modal/alert/alert.tpl.html',
            controller: 'alertController as vm',
            size: 'md',
            resolve: {
                alertData: function() {
                    return {
                        message: message,
                        type: 'QUESTION',
                        customButtons: confirmProperties.button1 && confirmProperties.button2 ? [confirmProperties.button1, confirmProperties.button2] : undefined,
                        cancelButton: confirmProperties.cancelButton,
                        title: confirmProperties.title,
                        ignoreWhiteSpaces: confirmProperties.ignoreWhiteSpaces
                    }
                }
            },
            backdrop: true,
            keyboard: true
        });
    };

当调用我的函数时,除了“ ignoreWhiteSpaces”之外的所有属性都可以正常传递...即使我传递了false,它也会以未定义的形式出现。这是为什么?我花了一个多小时试图解决这个问题。

var confirmProperties = {
                    button1: 'Update Existing Contracts',
                    button2: 'No Update to Existing Contracts',
                    cancelButton: true,
                    title: 'Update Service on the Customers Existing Contracts',
                    ignoreWhiteSpace: false
                };
appState.confirm('This is the message.', confirmProperties);

enter image description here

1 个答案:

答案 0 :(得分:1)

您的代码中有错字。 ignoreWhiteSpace,而不是ignoreWhiteSpaces。 从以下位置更改代码:

var confirmProperties = {
                button1: 'Update Existing Contracts',
                button2: 'No Update to Existing Contracts',
                cancelButton: true,
                title: 'Update Service on the Customers Existing Contracts',
                ignoreWhiteSpace: false
            };

var confirmProperties = {
                button1: 'Update Existing Contracts',
                button2: 'No Update to Existing Contracts',
                cancelButton: true,
                title: 'Update Service on the Customers Existing Contracts',
                ignoreWhiteSpaces: false
            };