How to use Angularjs with TypeScript

I want to use Angularjs with TypeScript .

To resolve error TS2095: Could not find symbol 'angular' , I downloaded ts files from here and added links to controllers.ts as follows:

 /// <reference path="angular.d.ts" /> /// <reference path="jquery.d.ts" /> var mathML = angular.module('mathML', []); 

But I still have a similar error:

 angular.d.ts(33,28): error TS2095: Could not find symbol 'JQuery'. 

How can I solve this error? Is there a better way to configure the environment to use Angularjs using TypeScript ?

+7
javascript angularjs typescript
source share
1 answer

Using the following directory structure:

 |- angular |- angular.d.ts |- jquery |- jquery.d.ts |- mathML.ts 

I managed to get the following sample code for compilation without errors.

 /// <reference path="angular/angular.d.ts" /> var mathML = angular.module('mathML', []); 

The angular.d.ts file references the jquery.d.ts file using a relative path. The directory structure is pretty standard for typescript code.

+4
source share

All Articles