Angular材质$mdDialog与第二位置持有人

Angular material $mdDialog with second place holder

本文关键字:位置 持有人 材质 mdDialog Angular      更新时间:2023-09-26

我正试图添加第二个输入到一个角度材料对话框,但我不确定它是否可能。我试图添加Test2占位符,但没有工作。提前感谢您的帮助。

 $scope.showPrompt = function (ev) {
    $scope.statusTopic = '';
    var confirm = $mdDialog.prompt()
      .title('Test?')
      .placeholder('Test1')
      //.placeholder('Test2')
      .targetEvent(ev)
      .ok('Okay!')
      .cancel('Cancel');

下面是一个使用自定义对话框- CodePen的示例

标记
<div ng-controller="MyController as vm" ng-cloak="" ng-app="app">
  <md-button class="md-primary md-raised" ng-click="vm.open($event)">
    Custom Dialog
  </md-button>
  <div ng-if="vm.showText" layout="column">
    {{vm.placeholder1}}
    <br>
    {{vm.placeholder2}}
  </div>
  <script type="text/ng-template" id="test.html">
    <md-dialog aria-label="Test">
        <div layout-padding layout="column">
        <md-input-container>
            <label>Placeholder 1</label>
          <input ng-model="vm.placeholder1">
        </md-input-container>
        <md-input-container>
            <label>Placeholder 2</label>
          <input ng-model="vm.placeholder2">
        </md-input-container>
        <md-button ng-click="vm.save()" class="md-primary">Save</md-button>
      </div>
    </md-dialog>
  </script>
</div>

JS

angular.module('app',['ngMaterial'])
.controller('MyController', function($scope, $mdDialog) {
  this.open = function(ev) {
    this.showText = false;
    $mdDialog.show(
      {
        templateUrl: "test.html",
        clickOutsideToClose: true,
        scope: $scope,
        preserveScope: true,
        controller: function($scope) {
       },
    });
  };
  this.save = function () {
    this.showText = true;
    $mdDialog.cancel();
  }
})
演示:

https://material.angularjs.org/latest/demo/input

文档:

https://material.angularjs.org/latest/api/directive/mdDialoghttps://material.angularjs.org/latest/api/service/美元mdDialog