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";
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) {
}
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>