简体   繁体   中英

Visual Studio Code: Cannot find name angular?

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.

单击“angular”旁边的灯泡,然后选择“download typings”。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM