How to make a formControl readonly

If you are using Reactive Forms you can assign it dynamically like in the example code below (email field) this.registerForm = this.formBuilder.group({ first_name: [”, Validators.required], last_name: [”, Validators.required], email: new FormControl({value: null, disabled: true}, Validators.required), password: [”, Validators.compose([Validators.required, Validators.email])], confirm_password: [”, Validators.required], }); If you want to get all the values including disabled controls you … Read more

Angular 5 Reactive Forms – Radio Button Group

I tried your code, you didn’t assign/bind a value to your formControlName. In HTML file: <form [formGroup]=”form”> <label> <input type=”radio” value=”Male” formControlName=”gender”> <span>male</span> </label> <label> <input type=”radio” value=”Female” formControlName=”gender”> <span>female</span> </label> </form> In the TS file: form: FormGroup; constructor(fb: FormBuilder) { this.name=”Angular2″ this.form = fb.group({ gender: [”, Validators.required] }); } Make sure you use Reactive … Read more

Requiring a checkbox to be checked

Since Angular 2.3.1 you can use Validators#requiredTrue: Component: this.formGroup = this.formBuilder.group({ cb: [false, Validators.requiredTrue] }); Template: <form [formGroup]=”formGroup”> <label><input type=”checkbox” formControlName=”cb”> Accept it</label> <div style=”color: red; padding-top: 0.2rem” *ngIf=”formGroup.hasError(‘required’, ‘cb’)”> Required </div> <hr> <div> <button type=”submit” [disabled]=”formGroup.invalid”>Submit</button> </div> </form> STACKBLITZ DEMO

How to use formControlName and deal with nested formGroup?

you can use Form group which is basically a collection of controls ( controls mean the fields given in your html form) define in your typescript syntax and binded to your HTML elements using the formControlName directive ,for example this.myForm = fb.group({ ‘fullname’: [”, Validators.required], ‘gender’: [], ‘address’: fb.group({ ‘street’: [”], ‘houseNumber’: [”], ‘postalCode’: [”] … Read more

How to set value to form control in Reactive Forms in Angular

Setting or Updating of Reactive Forms Form Control values can be done using both patchValue and setValue. However, it might be better to use patchValue in some instances. patchValue does not require all controls to be specified within the parameters in order to update/set the value of your Form Controls. On the other hand, setValue … Read more

Angular 5 FormGroup reset doesn’t reset validators

It (FormGroup) behaves correctly. Your form requires username and password, thus when you reset the form it should be invalid (i.e. form with no username/password is not valid). If I understand correctly, your issue here is why the red errors are not there at the first time you load the page (where the form is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)