角度.js:12408 错误:[$parse:语法] ng 模式上的语法错误



我的代码:

<input ng-required="{{ ixarisCurrOpts[0].selected }}" 
      ng-pattern="[0R]{2}[a-zA-Z0-9_-]{23}" ng-click="returnFundAccGBP()" 
      ng-focus="fFundAccGBP=true" 
      ng-change="returnFundAccGBP()" ng-blur="fFundAccGBP=false" 
      ng-model="fundAccGBP" id="fundAccGBP" name="fundAccGBP" type="text" 
      placeholder="{{ fundAccRegexPrefix }}ACO_EpAn03f8X-DyWAc0n3L"
      class="form-control input-md" maxlength="25" ng-class="fFundAccGBPDef">

我在谷歌浏览器调试器中不断收到此错误:

错误:

[$parse:语法] 语法错误:标记"R"是意外的,期望表达式 [[0R]{2}[a-zA-Z0-9_-]{23}] 的第

3 列从 [R]{2}[a-zA-Z0-9_-]{23}] 开始出现 []]。

补充已经说过的内容:您应该分别在模式的开头和结尾使用"^"和"$":

"/^[0R]{2}[a-zA-Z0-9_-]{23}$^/"

这样,您可以断言模式从字符串的开头到结尾开始工作。

您的ng-pattern语法不正确。它必须在 fwd 内。 斜杠/.../ .

将其更改为 ng-pattern="/^[0R]{2}[a-zA-Z0-9_-]{23}$/" 。它会起作用。

模式正则表达式也更新了。

最新更新