Mam skrypt here, a ng-pattern działa poprawnie, ponieważ scope.subnet jest wyświetlane w Output tylko po dopasowaniu wzorca pattern. Ale ng-show nie wyświetla żadnego błędu jeśli ng-wzór nie jest dopasowany
<body ng-contoller="myConfigGenCtr">
<form novalidate name="myForm">
<div class="form-group">
<label for="hostname">Firewall hostname</label>
<input type="text" ng-model="hostname" class="form-control" id="hostname">
</div>
<div class="form-group">
<label for="subnet">Firewall subnet</label>
<input type="text" ng-model="subnet" class="form-control" id="subnet"
required ng-pattern="/^(?:[0-9]{1,3}\.){3}/" >
<div class="custom-error" ng-show="myForm.subnet.$error.pattern">
Not a valid subnet, should be i.e. 10.x.y. (3 bytes only)</div>
</div>
</form>
<div>Output: {{subnet}}</div>
</body>
co wzorzec powinien pasować? czy mógłbyś podać przykład? –
tj. 1.1.1. wyświetla się dobrze. Ale jeśli piszę 1.1 błąd nie pokazuje się – irom