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
无法正常工作