Angular-Material:md-dialog 中的 md-select 未关闭

Fre*_*ego 3 javascript angularjs angular-material mddialog md-select

我创建了一个简单的指令,它包含在一个表单中,只有几个 md-input 和一个md-select.

我现在在几页中使用了我的指令,一切正常,但现在我想在一个 md-dialog它没有按预期工作,如果我在它外面单击,我将无法关闭 md-select-menu ,即使我专注于 md 输入。

因此,用户关闭菜单的唯一两种方法是选择一个选项或关闭对话框。

这还不错,但我发现这很烦人。

这是对话框的内容:

<md-dialog aria-label="Modal" ng-cloak flex="75">
    <md-toolbar ng-class="md-primary">
        <div class="md-toolbar-tools">
            <h2 translate>personModal.update</h2>
            <span flex></span>
            <md-button class="md-icon-button" ng-click="cancel()">
                <md-icon md-svg-src="img/ic_close_white.svg" aria-label="Close dialog"></md-icon>
            </md-button>
        </div>
    </md-toolbar>
    <person-form person="person"></person-form>
</md-dialog>
Run Code Online (Sandbox Code Playgroud)

和指令内容:

<form name="createPersonForm" layout="row" layout-align="space-between center" class="bg-sec query-fields">
    <md-input-container flex class="full-width-input">
        <label translate>createPerson.form.firstname</label>
        <input name="firstname" ng-model="person.firstname" required md-asterisk/>
        <div ng-messages="createPersonForm.firstname.$error"
             ng-show="createPersonForm.firstname.$touched">
            <div ng-message="required" translate>
                createPersonForm.errors.firstnameMissing
            </div>
        </div>
    </md-input-container>

    <!--                      -->
    <!-- Other md-inputs here -->
    <!--                      -->

    <md-input-container flex class="consumption-filter full-width-input">
        <label translate>createPerson.form.contact</label>
        <md-select name="contact" ng-model="person.contactId" required>
            <md-option ng-repeat="contact in contacts" ng-value="{{contact.id}}">
                <span>{{contact.name}}</span>
            </md-option>
        </md-select>
        <div class="md-errors-spacer"></div>
        <div ng-messages="createPersonForm.contact.$error"
             ng-show="createPersonForm.contact.$touched">
            <div ng-message="required" translate>
                createPersonForm.errors.contactMissing
            </div>
        </div>
    </md-input-container>

    <md-button class="md-raised bg-white" ng-click="createPerson()" ng-disabled="createPersonForm.$invalid" ng-hide="loading" ><span translate>createPersonForm.errors.createButton</span></md-button>
    <md-progress-circular md-mode="indeterminate" class="md-accent" ng-show="loading"></md-progress-circular>
</form>
Run Code Online (Sandbox Code Playgroud)

我正在使用 Angular 1.5 和 Angular Material 1.0 。

我尝试玩弄 z-index,并升级 angular/angular 材料,但这并没有解决问题。

我正在考虑在 md-select 失去焦点时以编程方式关闭菜单,但我发现这有点难看。我还不知道该怎么做。

提前致谢 !

Lih*_*ini 5

使用上面 Freego 提出的方法在 angular-material 1.1.5 上给我抛出了一个错误

TypeError: Cannot read property '$viewValue' of undefined
Run Code Online (Sandbox Code Playgroud)

我通过设置z索引为这个固定在角材料1.1.5<md-backdrop />旁边.md-select-menu-container

.md-select-menu-container {
    z-index: 900;
}

md-backdrop.md-select-backdrop {
    z-index: 899;
}
Run Code Online (Sandbox Code Playgroud)