regex - In the angular, how can we check if a value match a pattern? -
how can check if value match pattern in code?
not use ng-pattern in function.
thanks.
use pure javascript match function.
var str = "the rain in spain stays in plain"; var res = str.match(/ain/g);
res array matched values. can test if there match checking array length:
if ( res.length > 0 ) console.log("match");
from here
use in directive, better controller since in angular 2 there no controllers.
Comments
Post a Comment