小编Sri*_*mGr的帖子

Angular 5 反应式表单模式验证器

我需要使用 Validators.pattern 在响应式表单(表单控件)中提出验证模式。条件是字母数字,只允许使用下划线_、连字符-。不应允许任何类型的空间。是否有任何一种模式可以帮助我实现这一目标。

谢谢。

angular angular-reactive-forms

5
推荐指数
2
解决办法
1万
查看次数

如何在Angular 6中的click事件上对matInput元素设置自动对焦?

与Google登录页面类似,单击事件后,我希望自动聚焦于输入元素。我尝试了@ViewChild('id')和document.getElementId('id')。两者都不起作用。它始终为null或未定义。我该如何实现?

       <mat-form-field class="example-full-width col-sm-4">
        <input autofocus id="login-username" matInput 
       formControlName="userName" minlength="5" maxlength="20" 
       name="userName" placeholder="Username" required #input> 
      </mat-form-field>

        <div class="col-sm-12">
           <button (click)="changeView()" type="button" mat-raised-
             button color="primary">Next</button>
          </div>

         <mat-form-field class="example-full-width col-sm-4" 
          #passwordInput>
        <input autofocus type="password" matInput 
       placeholder="Password" minlength="5" maxlength="20" 
       formControlName="userPassword" #passwordInput>  
      </mat-form-field>
Run Code Online (Sandbox Code Playgroud)

html5 angular-material angular

2
推荐指数
3
解决办法
4534
查看次数