How to use the @angular/common.Control function in @angular/common

To help you get started, we’ve selected a few @angular/common 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 datatypevoid / vulgar / src / client / app / register / register.component.ts View on Github external
constructor(private authService: AuthService,
              private formBuilder: FormBuilder,
              private router: Router,
              private usernameValidator: DebouncingUsernameValidator) {
    // Setup each of our controls using the `Control` `API`
    this.username = new Control('', Validators.compose([
      Validators.required,
      Validators.minLength(3),
      Validators.maxLength(16),
    ]), usernameValidator.usernameTaken)
    this.password = new Control('', Validators.compose([
      Validators.required,
      Validators.minLength(8),
      Validators.maxLength(128)
    ]))
    this.confirm = new Control('', Validators.compose([
      Validators.required,
      Validators.minLength(8),
      Validators.maxLength(128)
    ]))
    this.email = new Control('', Validators.compose([
      Validators.required,
github bradyhouse / house / fiddles / nativeScript / fiddle-0000-Template / src / client / app / frameworks / i18n.framework / components / lang-switcher.component.ts View on Github external
store.take(1).subscribe((s: any) => {
      // s && s.18n - ensures testing works in all cases (since some tests dont use i18n state)
      this.langForm = new ControlGroup({
        lang: new Control(s && s.i18n ? s.i18n.lang : '')
      });
    });
github justindujardin / ng2-material / src / components / form / validators_spec.ts View on Github external
it("should error when given nonsense values", () => {
        expect(v(new Control(null))).toEqual({mdNumberRequired: true});
        expect(v(new Control(undefined))).toEqual({mdNumberRequired: true});
        expect(v(new Control('sunset'))).toEqual({mdNumberRequired: true});
      });
    });
github dreamfactorysoftware / ionic-sdk / app / pages / register / register.ts View on Github external
constructor(private httpService: BaseHttpService, private formBuilder: FormBuilder, private nav: NavController, navParams: NavParams, private notificationService: NotificationService) {
        this.form = formBuilder.group({
            first_name: new Control('', Validators.compose([Validators.minLength(3), Validators.maxLength(50), Validators.required])),
            last_name: new Control(''),
            email: new Control('', Validators.compose([Validators.maxLength(50), ValidationService.emailValidator, Validators.required])),
            password: new Control('', Validators.compose([Validators.minLength(6), Validators.maxLength(50), Validators.required]))

        });
    }
github DSpace-Labs / angular2-ui-prototype / src / app / dspace / components / community-create.component.ts View on Github external
this.subscription = this.formService.getForm('community').subscribe(inputs => {
            this.inputs = inputs;
            let formControls = {};
            for(let input of this.inputs) {
                input.value = input.default ? input.default : '';
                let validators = this.formService.createValidators(input);
                formControls[input.id] = new Control('', Validators.compose(validators));
            }
            this.form = this.builder.group(formControls);
            this.active = true;
        },
        errors => {
github revov / uci-gui / public / app / components / login.component.ts View on Github external
constructor (
        private _authenticationService: AuthenticationService,
        private _formBuilder: FormBuilder,
        private _router: Router,
        private _logger: LoggerService
    ) {
        this.emailControl = new Control(
            "", 
            Validators.compose([Validators.required, Email.validate])
        );

        this.passwordControl = new Control(
            '',
            Validators.compose([Validators.required, Validators.minLength(1)])
        );

        this.form = this._formBuilder.group({
            email: this.emailControl,
            password: this.passwordControl
        });
    }
github teki-io / teki / client / src / client / app / shared / i18n / components / lang-switcher.component.ts View on Github external
constructor(private multilang: MultilingualService) {
    this.langForm = new ControlGroup({
      lang: new Control('en')
    });
  }
  changeLang(e: any) {
github dreamfactorysoftware / ionic-sdk / app / pages / group / group.ts View on Github external
import * as constants from '../../config/constants';



@Component({
    templateUrl: 'build/pages/group/group.html',
    //styleUrls: ['./components/group/group.css'],
    providers: [GroupService, ContactGroupService, ContactService, BaseHttpService, NotificationService],
    directives: [FORM_DIRECTIVES]
})

export class GroupCmp {
    form: ControlGroup;

    id = new Control('');
    name = new Control('', Validators.compose([Validators.maxLength(45), Validators.required]));

    selectedContactId: number = null;

    group: Group = new Group();
    contactGroups: Array < ContactGroup > = [];
    remainingContacts: Array < Contact > = [];

    public groups: Group[] = [];
    constructor(private notificationService: NotificationService, private groupService: GroupService, private contactService: ContactService, private contactGroupService: ContactGroupService, private formBuilder: FormBuilder, private nav: NavController, navParams: NavParams) {

        var groupId: string = navParams.get('id');

        if (groupId) {
            let self = this;
            var contactGroupParams = new URLSearchParams();
github Farata / angular2typescript / chapter8 / http_websocket_samples / client / app / main_form_programmatic.ts View on Github external
constructor(private http: Http) {
    this.myForm = new ControlGroup({
      productID: new Control()
    });
  }
github dreamfactorysoftware / ionic-sdk / app / pages / contact-info / contact-info.ts View on Github external
templateUrl: './build/pages/contact-info/contact-info.html',
    //styleUrls: ['./build/pages/contact-info/contact-info.css'],
    providers: [ContactService, BaseHttpService, ContactGroupService, ContactInfoService, GroupService, NotificationService],
    directives: [FORM_DIRECTIVES]
})

export class ContactInfoCmp {

    form: ControlGroup;

    id = new Control('');
    address = new Control('', Validators.compose([Validators.minLength(2),Validators.maxLength(50), Validators.required]));
    infoType = new Control('', Validators.required);
    city = new Control('', Validators.compose([Validators.minLength(2),Validators.maxLength(50), Validators.required]));
    state = new Control('', Validators.compose([Validators.minLength(2),Validators.maxLength(20), Validators.required]));
    country = new Control('', Validators.compose([Validators.minLength(2),Validators.maxLength(20), Validators.required]));
    email = new Control('', Validators.compose([Validators.maxLength(50), ValidationService.emailValidator, Validators.required]));
    phone = new Control('', Validators.compose([Validators.maxLength(50),Validators.minLength(10), ValidationService.phoneNumberValidator, Validators.required]));
    zip = new Control('', Validators.compose([Validators.maxLength(50),Validators.minLength(5), ValidationService.zipCodeValidator, Validators.required]));

    infoTypes = ['home', 'work', 'mobile'];

    contactInfo: ContactInfo = new ContactInfo();
    contactGroups: Array < ContactGroup > = [];
    remainingGroups: Array < Group > = [];
    selectedGroupId: number = null;

    constructor(private nav: NavController, navParams: NavParams, private formBuilder: FormBuilder, private contactInfoService: ContactInfoService, private httpService: BaseHttpService, private notificationService: NotificationService, private contactService: ContactService, private groupService: GroupService, private contactGroupService: ContactGroupService) {

        var id: string = navParams.get('id');
        this.contactInfo.contactId = navParams.get('contactId');
        if (id) {