angular2 forms - angular 2 : after submitting data the validation is fire -
i not using form tag in html code data clear , route injected validation fire after make submit , new
<div class="col-lg-6 col-md-8"> <input type="text" [disabled]="!iseditable" class="form-control" id="field-1" name="field1" pattern = "^[0-9]*$" placeholder="" maxlength="30" required [(ngmodel)]="country.countrycode" #field1 = ngmodel> <div class="alert alert-danger" [hidden]=" (field1.valid || field1.pristine)"> <ul> <li> in vlaid name </li> <li [hidden]="errordata.errordetails?.countrycode==null">{{errordata.errordetails?.countrycode}}</li> </ul> </div> </div>
if (this.country.id == 0 || this.country.id == undefined) { // add this.dataservice.add("country/save", this.country).then((status: any) => { if (status.success == false) { } else if (saveaction == 'savenew') { this.country = {}; } else if (saveaction == 'saveback') { this.router.navigate(['/comm/country']); } });
<section *ngif="active"> <div class="col-lg-6 col-md-8"> <input type="text" [disabled]="!iseditable" class="form-control" id="field-1" name="field1" pattern = "^[0-9]*$" placeholder="" maxlength="30" required [(ngmodel)]="country.countrycode" #field1 = ngmodel> <div class="alert alert-danger" [hidden]=" (field1.valid || field1.pristine)"> <ul> <li> in vlaid name </li> <li [hidden]="errordata.errordetails?.countrycode==null">{{errordata.errordetails?.countrycode}}</li> </ul> </div> </div>
this.active = false; settimeout(() => this.active = true, 0);
Comments
Post a Comment