Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebStorm - "angular" is not defined

Tags:

NOTE: This is a WebStorm issue, not an angular.js issue.

Screencast of the problem: http://f.cl.ly/items/302s0d1k1i3i1B2p0W09/ws703-angular-not-defined.mp4

Description:

I have the following in my index.html file:

<script src="vendor/js/angular.min.js"></script>
<script src="app/js/scratch.js"></script>

In scratch.js when I reference "angular" I keep getting this "angular is not defined" message from JSHint. How do I make it so angular is seen as defined in this file so JSHint stops complaining about it? Is this a configuration issue? Please advise.

WebStorm v7.0.3 / Mac OSX v10.9.1

like image 832
RBR Avatar asked Feb 09 '14 22:02

RBR


People also ask

What is the difference between AngularJS and angular CLI?

In a very simple words, Angular CLI is a command line interface for writing or easily setting/building up an angular application. Angular js - is a older version of Angular (version 1. x) which is a open-source JavaScript-based front-end web application framework.

How do I import an existing angular project into Intellij?

Open the application sources that are already on your machine Click Open or Import on the Welcome screen or select File | Open from the main menu. In the dialog that opens, select the folder where your sources are stored.


2 Answers

In

Webstorm settings > JavaScript > Code Quality Tools > JSHint 

there is "Predefined" line. Click on "Set" next to it. Here you can add all your predefined variables.

like image 189
coolicz Avatar answered Oct 12 '22 00:10

coolicz


The very first example in the documentation page of JSHint is the following:

Configuration file is a simple JSON file that specifies which JSHint options to turn on or off. For example, the following file will enable warnings about undefined and unused variables and tell JSHint about a global variable named MY_GLOBAL.

{
  "undef": true,
  "unused": true,
  "globals": { "MY_GLOBAL": false }
}

Replace MY_GLOBAL with angular, and you won't have this JSHint warning anymore.

like image 38
JB Nizet Avatar answered Oct 12 '22 02:10

JB Nizet