简体   繁体   中英

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.

My services getAllDomain is done.

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"

  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'. 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('|')+")";
      }
    );
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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