Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/385.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript AngularJS材质如何将文本字段作为提示对话框的密码?_Javascript_Angularjs - Fatal编程技术网

Javascript AngularJS材质如何将文本字段作为提示对话框的密码?

Javascript AngularJS材质如何将文本字段作为提示对话框的密码?,javascript,angularjs,Javascript,Angularjs,我正在使用AngularJS材质库,我试图弹出一个提示对话框,让用户输入密码 对话框工作正常,但问题是文本字段不是“password”类型,并且密码是可见的 有没有办法将文本字段设置为键入密码? 或者唯一的方法是创建自定义对话框 这是AngularJS材料网站上的一个示例: $scope.showPrompt = function(ev) { // Appending dialog to document.body to cover sidenav in docs app var confirm

我正在使用AngularJS材质库,我试图弹出一个提示对话框,让用户输入密码

对话框工作正常,但问题是文本字段不是“password”类型,并且密码是可见的

有没有办法将文本字段设置为键入密码? 或者唯一的方法是创建自定义对话框

这是AngularJS材料网站上的一个示例:

$scope.showPrompt = function(ev) {
// Appending dialog to document.body to cover sidenav in docs app
var confirm = $mdDialog.prompt()
  .title('What would you name your dog?')
  .textContent('Bowser is a common name.')
  .placeholder('Dog name')
  .ariaLabel('Dog name')
  .initialValue('Buddy')
  .targetEvent(ev)
  .required(true)
  .ok('Okay!')
  .cancel('I\'m a cat person');

$mdDialog.show(confirm).then(function(result) {
  $scope.status = 'You decided to name your dog ' + result + '.';
}, function() {
  $scope.status = 'You didn\'t name your dog.';
});
};


谢谢。

要创建密码输入字段,我只需在html标记中设置类型

<input type="password">

请参考以下代码:

<md-input-container class="md-block logininput" flex-gt-sm>
    <label>key</label>
    <input type="password" ng-model="user.key" required>
    <div ng-messages="userForm.postalCode.$error" role="alert" multiple>
        <div ng-message="required" class="my-message">Please input a password!</div>
    </div>
</md-input-container>

钥匙
请输入密码

提示是一个预置对话框,您需要使用自定义对话框

 $scope.showAdvanced = function() 
{
    $mdDialog.show({
      controller: DialogController,
      templateUrl: './html/dialog1.tmpl.html', //custom template to load on the dialog
      parent: angular.element(document.body),
      clickOutsideToClose:true,
      fullscreen: $scope.customFullscreen // Only for -xs, -sm breakpoints.
    })
    .then(function(answer) {
      $scope.status = 'You said the information was "' + answer + '".';
    }, function() {
      //close the dialog
    });
};
对话框控制器

 function DialogController($scope, $mdDialog) {
    $scope.hide = function() {
      $mdDialog.hide();
    };

    $scope.cancel = function() {
      $mdDialog.cancel();
    };

    $scope.answer = function(answer) {
      $mdDialog.hide(answer);
    }
  } // dialog controller end
在模板中,您只需添加所需的代码

 <md-input-container style="margin-top:50px">
    <label style="border-color: white; color: white; text-align:left;">Contraseña</label>
        <input type="password" name="pass" ng-model="pass" required md-no-asterisk >
               <div ng-messages="ingresoForm.pass.$error">
               <div ng-message="required">Este campo es requerido</div>
        </div>

 </md-input-container>

康瑟斯尼娜
埃斯特坎波酒店
最后打电话给你的对话

$scope.showAdvanced()

您可以在此处查看整个文档:


你好

它不知道它真正做了什么,只说
,它是什么意思?:)