How to use the @angular/forms.FormBuilder function in @angular/forms

To help you get started, we’ve selected a few @angular/forms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rxweb / rxweb / test / reactive-form-validators / validator / lessThanEqualTo.validator.spec.ts View on Github external
() => {
          let formBuilder = new FormBuilder();
          let formGroup = formBuilder.group({
'totalMarks':[10],
            'obtainedMarks':105
          });
          expect(RxwebValidators.lessThanEqualTo({fieldName:'totalMarks',conditionalExpression:(x,y) => x.totalMarks == 100 })(formGroup.controls.obtainedMarks)).toBeNull()
        });
github rxweb / rxweb / test / reactive-form-validators / validator / not.validator.spec.ts View on Github external
() => {
        let formBuilder = new FormBuilder();
        let formGroup = formBuilder.group({
          'dob': "09/02/2019",
          'licenseDate': "10/02/2019"
        });
        expect(RxwebValidators.not({validation:{minDate:{fieldName:'dob',operator:">="},contains:{value:"-"}}})(formGroup.controls.licenseDate)).toEqual({'not':{ message: 'not condition failed.', refValues: [ "10/02/2019" ] } });
      });
github rxweb / rxweb / test / reactive-form-validators / validator / upperCase.validator.spec.ts View on Github external
() => {
          let formBuilder = new FormBuilder();
          let formGroup = formBuilder.group({
			'countryName':['INDIA'],
            'stateName':'Gujarat'
          });
          expect(RxwebValidators.upperCase({conditionalExpression:(x,y) => x.countryName == "INDIA" })(formGroup.controls.stateName)).toEqual({'upperCase':{ message: 'Only upper case are allowed.', refValues: [ 'Gujarat' ] } }); 
        });
github rxweb / rxweb / test / reactive-form-validators / validator / compare.validator.spec.ts View on Github external
() => {
          let formBuilder = new FormBuilder();
          let formGroup = formBuilder.group({
			'password':['User@123'],
            'confirmPassword':'user@123'
          });
          expect(RxwebValidators.compare({fieldName:'password',message:'You must enter same password'})(formGroup.controls.confirmPassword)).toEqual({'compare':{ message: 'You must enter same password', refValues: [ 'user@123','User@123' ] } }); 
        });
github ordercloud-api / ngx-shopper / src / UI / Seller / src / app / auth / containers / forgot-password / forgot-password.component.spec.ts View on Github external
describe('ngOnInit', () => {
    const formbuilder = new FormBuilder();
    beforeEach(() => {
      component.ngOnInit();
    });
    it('should set the form values to empty strings', () => {
      expect(component.resetEmailForm.value).toEqual({
        email: '',
      });
    });
  });
  describe('onSubmit', () => {
github Farata / angular2typescript / chapter7 / form-samples-rc4 / app / 07_form-builder.ts View on Github external
constructor() {
    const fb = new FormBuilder();
    this.formModel = fb.group({
      'username': ['', Validators.required],
      'ssn': ['', ssnValidator],
      'passwordsGroup': fb.group({
        'password': ['', Validators.minLength(5)],
        'pconfirm': ['']
      }, {validator: equalValidator})
    });
  }
github graycoreio / daffodil / apps / demo / src / app / checkout / components / shipping / shipping-options / components / shipping-options / shipping-options.component.spec.ts View on Github external
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ShippingOptionsComponent } from './shipping-options.component';
import { Component } from '@angular/core';
import { By } from '@angular/platform-browser';
import { FormGroup, FormBuilder, FormsModule, ReactiveFormsModule, FormControl, Validators } from '@angular/forms';
import { ShippingOptionsService } from '../services/shipping-options.service';
import { ShippingOptionsFactory } from '../factories/shipping-options.factory';

const formBuilder: FormBuilder = new FormBuilder();

const stubFormGroupValue = formBuilder.group({
  id: ['', Validators.required]
});
const stubSubmitted = false;

@Component({
  template: ''
})
class WrapperComponent {
  formGroupValue: FormGroup = stubFormGroupValue;
  submittedValue: boolean = stubSubmitted;
};
github GetTerminus / terminus-ui / src / lib / src / search / search.component.spec.ts View on Github external
beforeEach(() => {
    this.component = new TsSearchComponent(new FormBuilder());
  });
github Farata / angular2typescript / chapter7 / auction / app / components / search / search.ts View on Github external
constructor(private productService: ProductService) {
    this.categories = this.productService.getAllCategories();

    const fb = new FormBuilder();
    this.formModel = fb.group({
      'title': [null, Validators.minLength(3)],
      'price': [null, positiveNumberValidator],
      'category': [-1]
    })
  }
github GetTerminus / terminus-ui / src / lib / src / login-form / login-form.component.spec.ts View on Github external
beforeEach(() => {
    this.component = new TsLoginFormComponent(
      new FormBuilder(),
      new TsValidatorsServiceMock(),
    );
  });