为什么? ng-pattern在我的指令上不起作用

时间:2018-07-31 15:35:26

标签: angularjs

angularjs代码

app.directive("textPan", function() {
  return {
    scope: {
      name: "@",
      label: "@",
      id: "=",
      readonly: "@",
      pattern: "@"
    },
    template: [
      ' <div class="form-group">',
      ' <label class="control-label" id="lbl{{name}}">{{label}}</label>',
      ' <input   id="txt{{name}}" class="form-control" ng-model="val" name="txt{{name}}" ng-readonly={{readonly}} ng-pattern="/^[A-Za-z]{5}\d{4}[A-Za-z]{1}$/"   required />',
      ' <span ng-show="myForm.txt{{name}}.$error.required" class="text-danger ">This field is required.</span>',
      '<span ng-show="myForm.txt{{name}}.$error.pattern" class=""><em></em>PAN CARd is not valid</span>',
      ' </div>'
    ].join("")
  };
});

问题在于一切正常,但是ng-pattern无法正常工作

0 个答案:

没有答案