Using AngularJS
This feature is supported in the Ultimate edition only.
IntelliJ IDEA provides integration with the AngularJS framework also known as Angular 1. This support involves:
- AngularJS-aware code completion for
ng
directives (also including custom directives), controller and application names, and code insights for data bindings inside curly-brace expressions{{}}
. - AngularJS-specific navigation:
- A collection of AngularJS built-in live templates.
- Quick documentation look-up by pressing Ctrl+Q, see Viewing Inline Documentation for details.
- AngularJS ui-router diagram.
Before you start
- Install the Node.js runtime environment.
- Make sure the AngularJS plugin is installed and enabled. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
Introduction
You can get AngularJS support in a IntelliJ IDEA project in the following ways:
- Open an existing project with AngularJS sources.
- Generate an AngularJS-specific project stub from the IntelliJ IDEA Welcome Screen. IntelliJ IDEA generates the AngularJS-specific project structure with all the required configuration files based on the AngularJS seed project
- Create an empty project , and then install AngularJS in it either manually, by downloading the AngularJS framework, or using the Bower package manager. If you choose manual installation, you will need to configure AngularJS as a IntelliJ IDEA JavaScript library. If you use Bower, IntelliJ IDEA will do this configuration automatically, without any steps from your side.
Creating an AngularJS project using a seed project
- Choose on the main menu or click the New Project button on the Welcome screen.
- In the Project Category and Options dialog, which is the first page of the New Project wizard, choose Static Web in the left-hand pane.
- In the right-hand pane, choose AngularJS and click Next.
- On the second page of the wizard, specify the project name and the folder to create it in.
From the Version drop-down list, choose the branch https://github.com/angular/angular.js to download the project template from. By default,
master
if shown. - When you click Finish , IntelliJ IDEA generates the AngularJS-specific project structure with all the required configuration files based on the AngularJS seed project
- Download the AngularJS dependencies that contain the AngularJS code and the tools that support development and testing: launch the embedded Terminal ( or by hovering your mouse pointer over
in the lower left corner of IntelliJ IDEA and choosing Terminal from the menu and type
npm install
at the command line prompt. Learn more about the installation of dependencies in the Install Dependencies section of thereadme.md
file.
Configuring AngularJS support in a project
If you already have AngularJS sources in your project (for example, in the bower_components
folder), just open your project and start working. If these sources are excluded from project, then you only need to configure AngularJS as an External JavaScript library.
If you do not have any previously downloaded AngularJS sources, create an empty project create a Pure Python project, and then install AngularJS in it either manually, by downloading the AngularJS framework, or using the Bower package manager.
Creating an empty IntelliJ IDEA project
- Choose on the main menu or click the New Project button on the Welcome screen.
- In the Project Category and Options dialog, which is the first page of the New Project wizard, choose Static Web in the left-hand pane.
- In the right-hand pane, choose Static Web and click Next.
- On the second page of the wizard, specify the project name and the folder to create it in.
- When you click Finish , IntelliJ IDEA creates and opens an empty project.
Configuring AngularJS coding assistance in an empty project manually
- Download the AngularJS framework at http://angularjs.org/.
- Open the empty project where you will use AngularJS.
- Configure AngularJS as a IntelliJ IDEA JavaScript library, to let IntelliJ IDEA recognize AngularJS-specific structures and provide full coding assistance:
- Open the Settings/Preferences dialog box, and click JavaScript Libraries.
- In the Libraries area, click the Add button.
- In the New Library dialog box that opens, specify the name of the library.
- Click the Add button
next to the list of library files and choose Attach Files or Attach Directory on the context menu, depending of whether you need separate files or an entire folder.
- Select the
Angular.js
orAngular.min.js
, or an entire directory in the dialog box that opens. IntelliJ IDEA returns to the New Library dialog box where the Name read-only field shows the name of the selected files or folder. - In the Type field, specify which version you have downloaded and are going to add.
- If you added
Angular.js
, choose Debug. This version is helpful in the development environment, especially for debugging. - If you added the minified
Angular.min.js
, choose Release. This version is helpful in the production environment because the file size is significantly smaller.
- If you added
Installing AngularJS in an empty project through Bower
- Open the empty project where you will use AngularJS.
- Download, install, and configure Node.js as described in Configuring Node.js Interpreters.
- Install Bower as described in Using Bower Package Manager.
- Launch the embedded Terminal ( or by hovering your mouse pointer over
in the lower left corner of IntelliJ IDEA and choosing Terminal from the menu and type
bower install angular
at the command line prompt to install the package in the current project.
You can also install the angular
package on the Bower page of the Settings/Preferences dialog as described in Installing and Removing Bower Packages.
Using AngularJS Router state diagrams
You can see a diagram illustrating the relations between views, states, and templates in AngularJS applications that use ui-router.
To generate and view a diagram, open the desired file in the editor, and then choose on the context menu. IntelliJ IDEA generates a diagram and shows it in a separate editor tab.
To navigate from an element in the diagram to the code that implements this element, select it and choose Jump to Source on the context menu.