简体   繁体   English

如何使用 api 生成模式的动态响应表单模块

[英]how do dynamic reactiveFormsModule with patterns generate by api

I have an angular form group with an input mail but I want to add regex patterns for the extension for only what its in my database.我有一个带有输入邮件的 angular 表单组,但我想为扩展名添加正则表达式模式,仅用于我的数据库中的内容。

My services getAllDomain is done.我的服务 getAllDomain 已完成。

I don't know how to write the regex any word that does not end @ and a word from my list not case-similar我不知道如何编写任何不以 @ 结尾的单词和我列表中的单词不区分大小写的正则表达式

i think trigger action like that [pattern]="patternEmail"我认为触发这样的动作[pattern]="patternEmail"

  getpatternEmail(){
domainList: string[] = [];
this.domainService.getAll().subscribe({
      next:(res) => {
        domainList=res;
    }});
    
    return ".@("+domainList.join('|')+")";
  }

Property 'patternEmail' does not exist on type 'CreateComponent'

and if i remove the get Type '() => string' is not assignable to type 'string | RegExp'.如果我删除 get Type '() => string' is not assignable to type 'string | RegExp'. Type '() => string' is not assignable to type 'string | RegExp'.

something like this should work像这样的东西应该工作

get patternEmail(): string{
    domainList: string[] = [];
this.domainService.getAll().subscribe({
      next:(res) => {
        domainList=res;
    },
      error: (e) => {
      },
      () => {
        // 'onCompleted' callback.
        // No errors
       return ".@("+domainList.join('|')+")";
      }
    );
  }

暂无
暂无

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

相关问题 如何将formControlName赋予FormArray对象 - Angular 2(ReactiveFormsModule) - How to give formControlName to a FormArray object - Angular 2 (ReactiveFormsModule) 如何基于接收到的API数据生成动态template.html - How to generate dynamic template.html based on receive API data 如何在Angular8中使用基于API的数据生成动态选项卡 - How to generate dynamic tab with data based on API in Angular8 如何根据 API 响应在 angular 中生成动态菜单和组件 - how to generate dynamic menu and components in angular based on API response 如何根据Angular中的API数据生成动态tab - How to generate dynamic tab based on API data in Angular 如何在 angularJS2 中使用 ReactiveFormsModule 验证单选按钮? - How to validate Radio Buttons using ReactiveFormsModule in angularJS2? 如何使用Angular2 ReactiveFormsModule将数组绑定到复选框? - How to bind an array to checkbox using Angular2 ReactiveFormsModule? 如何在Angular中将ReactiveFormsModule和验证用于动态添加的控件? - How to use ReactiveFormsModule and validations for dynamically added controls in Angular? 你如何产生动态<style> tag content in Angular template at runtime? - How do you generate dynamic <style> tag content in Angular template at runtime? 如何在Angular的ReactiveFormsModule中压缩定义验证者和验证者列表的代码? - How can I compact the code defining the list of validatees and validators in ReactiveFormsModule of Angular?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM