简体   繁体   English

用于控制的角反应形式

[英]Angular reactive form for control

A social number input field must have format like below condition in reactive forms:社交号码输入字段必须具有类似以下条件的响应形式的格式:

  • Format must be ###-##-####.格式必须为###-##-####。
  • Limit size to 9 digits without the dashes (11 with dashes)将大小限制为 9 位不带破折号(11 位带破折号)
  • User does not enter dash (dash is not a numeric value用户没有输入破折号(破折号不是数值

Can anyone please help me in code of this format and requirement for this control任何人都可以帮助我编写此格式的代码和此控件的要求

form name: ownsForm
object:obj
formcontrol name========(social: this.Obj.social),

html html

<input matInput 
       placeholder="Social " 
       class="form-control input-sm" 
       formControlName="social">

Please provide the code in reactive angular form for .ts file and HTML file.请为.ts文件和 HTML 文件提供反应角度形式的代码。
I am taking input from the user.我正在接受用户的输入。

Had you try ngx-Mask package?您是否尝试过 ngx-Mask 包?

Here i had created simple stackblitz demo as per your requirement.在这里,我根据您的要求创建了简单的 stackblitz 演示。

https://stackblitz.com/edit/angular-zwtrch https://stackblitz.com/edit/angular-zwtrch

maybe you are talking about angular Pipes?也许你在谈论角管? this is what we can use for formatting, regular expressions, and transforms.这就是我们可以用于格式化、正则表达式和转换的内容。

https://angular.io/guide/pipes https://angular.io/guide/pipes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM