Access to ng sample in error message

I have ng-repeat for an attribute list and you want to display error messages for each input. For the pattern error, I also want to show which specific regular expression it needs to match.

Can I access the input template? I know that I can add an attribute containing a regular expression, but I would like to know if there is an angular way somehow.

(This is a simplified example, regular expressions may differ for different attributes)

<form name="form">
    <div data-ng-repeat="(attributeName, attributeMetaData) in configuration.metaData">

        <input data-ng-model="configuration[attributeName]" type="text" name="{{attributeName}}" data-ng-pattern="/^[0-9][0-9]:[0-9][0-9]$/">

        <span data-ng-show="form[attributeName].$error.pattern && form[attributeName].$dirty">
            Please check your input format [pattern should go here]
        </span>   
    </div>
</form>

jsFiddle: http://jsfiddle.net/lisapfisterer/ndu2g0ev/

+4
source share
1 answer

, , , - ,

+2

Source: https://habr.com/ru/post/1625136/


All Articles