0

I am trying out the new Angular 2 Forms. My import statements are as follows:

import {bootstrap, onChange, NgIf, Component, Directive, View, Ancestor} from 'angular2/angular2';
import {formDirectives, NgControl, Validators, NgForm} from 'angular2/forms';

import {RegExpWrapper, print, isPresent} from 'angular2/src/facade/lang';

import {reflector} from 'angular2/src/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities';

The 'angular2/angular2' resolves fine, but none of the other "from" locations resolve. The error is:

Cannot find module 'angular2/forms'.

All of these components are currently in my node_modules directory. If I put in the full path:

import {formDirectives, ControlDirective, Validators, TemplateDrivenFormDirective} from 'C:/Users/Deb/node_modules/angular2/forms';

then it works. However, I should not need to use the full path. Am I missing something when I set up the tsconfig or is there something else wrong?

6
  • What kind of module loader are you using? System.js, Webpack, etc. ? The short path to the modules can be set there. Commented Jun 14, 2015 at 3:06
  • If it helps, here are some working angular2 boilerplates: tryangular2.com/category/Boilerplate Commented Jun 14, 2015 at 3:13
  • I'm using the new Visual Studio Code editor so assumed it was a setting there somewhere? Commented Jun 14, 2015 at 4:43
  • 1
    @DeborahK what you are missing is a .d.ts file for angular2 forms, when I was playing with it I created a shim of what I needed basically making all the things you need to import be of type any and you should be fine (once you reference it of course) Commented Jun 15, 2015 at 11:12
  • 1
    OK. I added the forms.d.ts file and set a reference path defining its location. Still getting the same issue: "can't find external module angular2/forms" Commented Jun 15, 2015 at 15:19

1 Answer 1

1

Problem was that the example application did not match with the version of Angular 2 currently available for download.

If anyone is interested, I now have a working example of Angular2 forms with TypeScript and Visual Studio Code here:

https://github.com/DeborahK/AngularU2015-Angular2Forms

Hope this helps anyone else standing on the "bleeding edge".

Sign up to request clarification or add additional context in comments.

1 Comment

Hi. I took a look at your sample. This might have changed again as I don't see the ng-control directive anymore.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.