javascript - How to add directive for extra validation properly in angular? -


What do I need: I need to add additional attributes for input by adding attributes to this input.

First of all, my PLNKR example

What did I try?: I gave directions, so when I add attribute to input, the value of the input is regexp ^ 5 $ . In addition, I added the input required for input I am now talking about 2 input (input name is input2 ).

So, I add "my specialty" and "necessary" properties. If there is nothing in the input, then give me myForm.item [1]. $ Error is expected of two items: its exact - attributes are myAttribute and required . Now, I will add something in input 2, for example "ABC", now let me call it myForm.item [1]. $ Error is required in the property only (because the required verification has been passed, but myAttribute is not validated), but myAttribute And parse in myForm.item [1]. Error . What is the parse property? Why is it adding to $ error ?

I should notice, when I input 5 to <2> myForm.item [1]. $ Error empties , because both require and passed myAttribute validations (and this behavior is expected).

Now, when I clear Input 2, then properties are pars and myAttribute . Why? When Field Input 2 is empty, then I Expected and myAttribute in myForm.item [1]. $ Error is expected, but none is there.

So, I get a $ error in strange property parse and how can I work my example?

The form was established to answer the approach to validate the input by establishing the example code and using the instructions.

What is a parsed property? Why is adding $ error?

Returns one of the parsers undefined when the parse property is automatically added by angular. From:

Returning from a parser to being unscheduled means a parsing error occurred. Any $ validators will run and will not be updated until the 'ngModel' parsing error is resolved. Parse error 'NGModel. $ Error.parse '.

Not sure that I'm missing out on some use here but changing from return should be enough parser:

East > // -> Model validation ngModel $ Parsers.unshift (function (value) {var Valid = New RegExp ("^ 5 $"). Test (value); ngmodel. $ SetValidity ('myAttribute', valid); return value;});

Comments