阻止md-dialog的滚动,当打开md-automplete时,它是md-automplete的父级

时间:2018-02-22 08:26:41

标签: javascript css angularjs angular-material

enter image description here 我在角度材料(1.1.6)的md对话框上有一个md-automplete,在打开md-automplete时,如果我们尝试滚动模态然后它允许这样做并将自动完成菜单保持为打开状态。 我希望它不允许滚动模式直到自动完成时间打开。 一旦关闭,它也可以允许滚动模态对话框。

我创建了codepen

Html如下所示:

<div ng-controller="DemoCtrl as ctrl" layout="column" ng-cloak="" class="autocompletedemoInsideDialog" ng-app="MyApp">
  <md-content class="md-padding">
    <p>
      Click the button below to open the dialog with an autocomplete.
    </p>

    <md-button ng-click="ctrl.openDialog($event)" class="md-raised">Open Dialog</md-button>
  </md-content>
<script type="text/ng-template" id="dialog.tmpl.html"><md-dialog aria-label="Autocomplete Dialog Example" style="overflow-y:auto">

  <md-toolbar>
    <div class="md-toolbar-tools">
      <h2>Autocomplete Dialog Example</h2>
  Where does it come from?
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.
      <span flex></span>
      <md-button class="md-icon-button" ng-click="ctrl.cancel()">
        <md-icon md-svg-src="img/icons/ic_close_24px.svg" aria-label="Close dialog"></md-icon>
      </md-button>
    </div>
  </md-toolbar>

  <md-dialog-content ng-cloak>
    <div class="md-dialog-content">
      <form ng-submit="$event.preventDefault()">
        <p>Use <code>md-autocomplete</code> to search for matches from local or remote data sources.</p>
        <md-autocomplete
            md-selected-item="ctrl.selectedItem"
            md-search-text="ctrl.searchText"
            md-items="item in ctrl.querySearch(ctrl.searchText)"
            md-item-text="item.display"
            md-min-length="0"
            placeholder="What is your favorite US state?"
            md-autofocus="">
          <md-item-template>
            <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.display}}</span>
          </md-item-template>
          <md-not-found>
            No states matching "{{ctrl.searchText}}" were found.
          </md-not-found>
        </md-autocomplete>
      </form>
    </div>
  </md-dialog-content>

  <md-dialog-actions>
    <md-button aria-label="Finished" ng-click="ctrl.finish($event)">Finished</md-button>
  </md-dialog-actions>
</md-dialog>
</script></div>

0 个答案:

没有答案