Search code examples
javascriptangulartypescriptangular-directive

How to use RegExp in Directive with validation with Angular 8


I have 8 angular application. and I have a directive with a RegExp for youtube and vimeo validation.

But after I declared the RegExp I can't use it in the directive.

So I have this:


Solution

  • You need to make urlPattern static as well, otherwise it's only visible to non-static methods. You will also then need to refer to it as EcheqUrlValidator.urlPattern.