Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

FormBuilder, Validators, ControlGroup, Control not imports #134

Open
harryjacksol opened this issue Sep 29, 2016 · 2 comments
Open

FormBuilder, Validators, ControlGroup, Control not imports #134

harryjacksol opened this issue Sep 29, 2016 · 2 comments

Comments

@harryjacksol
Copy link

harryjacksol commented Sep 29, 2016

Hi, I want to make validations to my project but i can not import FormBuilder, Validators, ControlGroup, Control.
I am getting following errors in console:
Errors:-
[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:22:13
Cannot find name 'ControlGroup'.

[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:24:27
Cannot find name 'FormBuilder'.

[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:26:26
Property 'formBuilder' does not exist on type 'Home'.

[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:27:23
Cannot find name 'Validators'.

[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:28:24
Cannot find name 'Validators'.

[default] /var/www/aaaa/angular2-seed/src/app/home/home.ts:28:45
Cannot find name 'Validators'.

I also attached my code here.

home.ts

import { Component, Input, trigger, state, style, transition, animate} from '@angular/core';
import {Http, Headers, RequestOptions, Response} from '@angular/http';
import { FormBuilder, Validators, ControlGroup, Control} from "@angular/common";

@component({
selector: 'home',
styleUrls: ['./home.css'],
templateUrl: './home.html'
})

export class Home {
public results;
loginForm: ControlGroup;

constructor(formBuilder: FormBuilder, private http:Http) {

this.loginForm = this.formBuilder.group({
  'username': ['', Validators.required],
  'password': ['', [Validators.required, Validators.minLength(3) ]]

});

}

login(event,username,userpassword) {
console.log(username);
}
}

home.html

< form class="login-form" [ngModelForm]="loginForm" [formGroup]="loginForm" *ngIf="ishidden1">
< h3 style="display:inline-block">< span class="glyphicon glyphicon-log-in" >< / h3 >
< h1 style="display:inline-block">Login< / h1 >
< input type="text" minlength="5" maxlength="8" required #username id="username" placeholder="username" ngControl="username" #username="ngForm" />
< input type="password" id="password" #password placeholder="password" ngControl="password" />
< button (click)="login($event,username.value,password.value)">login< /button>
< p class="message" (click)="clicked($event,false)">Not registered? < a href="#" class="message">Create an account< / a >< /p >
</ form>

@mruanova
Copy link

mruanova commented Nov 2, 2017

import from angular FORMS and not angular COMMON :) like this:

import { FormBuilder, Validators, ControlGroup, Control} from "@angular/forms";

@raghu77
Copy link

raghu77 commented Apr 14, 2018

bt it is also getting an error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants