3

I have an Angular App and it works fine, but my debugger is showing me 'Cannot find name angular'.

 var table = angular.module('myTable', ['angularUtils.directives.dirPagination']); 

I included the link for angular in my html file:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>

I tried also including a link for bower_components also:

<script src="bower_components/angular/angular.min.js"></script>

There is a answer about this problem at Getting Error - Cannot find name 'angular' but I am not able to use it.

Community
  • 1
  • 1
John Charger
  • 416
  • 6
  • 21

2 Answers2

7

Click on the lightbulb that will be next to 'angular' and then choose 'download typings'.

1

I was having the same issue until I ran across this article:

http://blogs.msdn.com/b/vscode/archive/2015/05/22/getting-started-with-angular-and-visual-studio-code.aspx

Basically, here's what you have to do with npm:

cd (app path)
npm install -g tsd
tsd init
tsd query angular --action install --save

That's it. When you restart VS Code your problem should be gone.

Note that I didn't use any of the ///reference links as the author suggested in the article, but after the above steps I stopped getting that message about angular not being found and I have already noticed more ng-* options coming through in Intellisense.

Graham
  • 7,431
  • 18
  • 59
  • 84
  • 1
    It did not help the problem is still there. – LEMUEL ADANE Dec 31 '16 at 15:02
  • It solved the problem when the question was asked, in that version of VS Code. – Graham Jan 01 '17 at 17:54
  • "tsd query angular --action install --save" now yields "zero results", at least for me. (tsd is deprecated in favor of typings?) – alecmce May 09 '17 at 10:05
  • 1
    Both Angular and VS Code were immature and frequently changing when this question and answer were posted. You shouldn't see this issue any more with Angular 4 and the latest VS Code. It's probably worth posting a new question here as the odds are practically zero that you've got the same issue as the original poster unless you haven't updated VS Code in over a year and are running pre-release Angular.. – Graham May 09 '17 at 13:22