3

I am using Angular 2.0 Alfa 35. When I am importing FORM_DIRECTIVES (which is a new name for formDirectives on Alfa 35) I am getting a Typescript error:

error TS2305: Module '"angular2/angular2"' has no exported member 'FORM_DIRECTIVES'.

Is it a bug in ts definitions? Can I fix/override it?

Cosmin Ababei
  • 7,003
  • 2
  • 20
  • 34
Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96

6 Answers6

7

As of today for Angular 2 Beta it should be:

import {FORM_DIRECTIVES} from 'angular2/common'
Wojciech Owczarczyk
  • 5,595
  • 2
  • 33
  • 55
3

Angular >= RC.5

import { FormsModule, ReactiveFormsModule } from '@angular/forms';

@NgModule({
  imports: [BrowserModule, FormsModule, ReactiveFormsModule],
  ...
})
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
2

Yup as we all know angular2 is in beta now so almost there is negligible chance of Breaking changes either it is the case of List of imports or any syntax, btw you can import necessary form imports from here...

import {CORE_DIRECTIVES, FORM_DIRECTIVES, NgClass, NgIf  NgForm, Control, ControlGroup, FormBuilder, Validators} from 'angular2/common';

for More list of all imports for angular2 beta you can refer here

update

as of updated angular2 RC there is change

import { FORM_DIRECTIVES } from '@angular/common';
Community
  • 1
  • 1
Pardeep Jain
  • 84,110
  • 37
  • 165
  • 215
2

All of the previous answers given are no longer workable. Angular2 now has an entirely different structure and package name in NPM.

For anything since Angular 2.0.0-rc.0 (from May 2, 2016), you have to use this for the old forms system:

import { FORM_DIRECTIVES } from '@angular/common';

Update: Or you can load it from here, if you are using the new Angular 2 forms system:

import { FORM_DIRECTIVES } from '@angular/forms';

You can read about it in the Angular 2 ChangeLog.

Michael Oryl
  • 20,856
  • 14
  • 77
  • 117
0

import {FORM_DIRECTIVES} from 'angular2/angular2';

worked for me with angular2@2.0.0-alpha.35

Guenther
  • 403
  • 2
  • 16
-2

As of today...

import { FORM_DIRECTIVES } from '@angular/form';
A. G. K
  • 33
  • 6