(AngularJS 2.0.8 - 3 2016 ):
https://github.com/angular/angular/commit/38cb526
:
<input [ngControl]="fullName" pattern="[a-zA-Z ]*">
, :) - :
<form (ngSubmit)="onSubmit(room)" #roomForm='ngForm' >
...
<input
id='room-capacity'
type="text"
class="form-control"
[(ngModel)]='room.capacity'
ngControl="capacity"
required
pattern="[0-9]+"
#capacity='ngForm'>
2017
, , , "" :
( angular !), - , (Restful API) , HTTP 400 json ( angular err):
this.err = {
"capacity" : "too_small"
"filed_name" : "error_name",
"field2_name" : "other_error_name",
...
}
( , )
html- (div/span/small ..)
<input [(ngModel)]='room.capacity' ...>
<small *ngIf="err.capacity" ...>{{ translate(err.capacity) }}</small>
, 'capacity', ( ). :
- angular , ( ) ( , ReDoS)
- , ( egzample
<small>) - error_name ( ), ( ), frontend- angular ( ). /.
, ( - , retypePassword, ), angular ( this.err ( pattern input, , , , ).