0

Tools I'm using... - Visual Studio 2015 - Gulp - TypeScript - Angular2

I've been struggling with importing in Typescript. I started reading ngBook2 and as I started the first example I noticed my import statement wasn't recognized by the IDE though Gulp had no problem Transpiling.

I found a reference that wasn't set correctly and that resolved that problem.

So this was not working but now is. import { bootstrap } from 'angular2/platform/browser';

Now I'm having trouble importing jquery. Seems like an easy enough thing to do but I can't seem to get it done.

I've uploaded the project onto GitHub. https://github.com/robertdunaway/katas-angular2/tree/master/001%20Angular2%20-%20getting%20started/after

When you load up the project the dependencies will be fetched. This will take a minute the first time. Then the default Gulp task will run and when it reaches the TypeStript code it errors.

Thanks, Bob

user3448990
  • 323
  • 6
  • 15
  • 1
    http://stackoverflow.com/questions/34762720/using-jquery-globaly-within-angular-2-application , http://stackoverflow.com/questions/30623825/how-to-use-jquery-with-angular2 – Langley Jan 14 '16 at 19:23
  • jquery is not written in ts so you can't import the modules like you do with angular, just add the js in your index file like you would normally do and it'll work, if you want to get rid of the ts errors because it doesn't recognize it, you have to download the jquery typings and put a reference to them – Langley Jan 14 '16 at 19:25
  • Oh, that makes a lot of sense. Obviously I've just recently started my TS journey and Angular2 just the other day. Lots to learn. So thanks a mill... – user3448990 Jan 14 '16 at 19:27

1 Answers1

0

jQuery is not written in ts so you can't import the modules like you do with angular, just add the js in your index file like you would normally do and it'll work, if you want to get rid of the ts errors because it doesn't recognize it, you have to download the jquery typings and put a reference to them:

using jQuery globaly within angular 2 application

How to use jQuery with Angular2?

Community
  • 1
  • 1
Langley
  • 5,326
  • 2
  • 26
  • 42