IntelliJ IDEA 2018.2 Help

AngularJS

IntelliJ IDEA integrates with the AngularJS framework also known as Angular 1 intended for developing single page web applications. IntelliJ IDEA suggests AngularJS-aware completion options for predefined and custom ng directives and for controller and application names, as well as code insights for data bindings inside curly-brace expressions {{}}. You can use built-in AngularJS live templates and navigate between the name of a controller in HTML and its definition in JavaScript or between ngView or &routeProvider and the template. For AngularJS entities, use the Go To Symbol navigation.

Before you start

  1. Install Node.js.

Creating a new AngularJS application

You can use the AngularJS seed project or create an empty IntelliJ IDEA project and install AngularJS in it either manually, by downloading the AngularJS framework, or with the Bower package manager.

To create an application using the seed project

  1. Choose File | New | Project on the main menu or click the New Project button on the Welcome screen.
  2. 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.
  3. In the right-hand pane, choose AngularJS and click Next.
  4. 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.

  5. When you click Finish, IntelliJ IDEA generates the AngularJS-specific project structure with all the required configuration files based on the AngularJS seed project

To download AngularJS dependencies, do one of the following:

  • Open the embedded Terminal (View | Tool Windows | Terminal or Alt+F12) and type npm install at the command prompt.
  • Choose Run 'npm install' on the context menu of the package.json file in your project root.

To create an empty IntelliJ IDEA project

  1. Choose File | New | Project on the main menu or click the New Project button on the Welcome screen.
  2. 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.
  3. In the right-hand pane, choose Static Web and click Next.
  4. On the second page of the wizard, specify the project name and the folder to create it in.
  5. When you click Finish, IntelliJ IDEA creates and opens an empty project.

To install and configure AngularJS in an empty project manually

  1. Download the AngularJS framework at http://angularjs.org/.
  2. Open the empty project where you will use AngularJS.
  3. Configure AngularJS as a IntelliJ IDEA JavaScript library, to let IntelliJ IDEA recognize AngularJS-specific structures and provide full coding assistance:
    1. Open the Settings/Preferences dialog box, and click JavaScript Libraries.
    2. In the Libraries area, click the Add button.
    3. In the New Library dialog box that opens, specify the name of the library.
    4. Click the Add button new 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.
    5. Select the Angular.js or Angular.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.
    6. 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.

To install AngularJS in an empty project through Bower

  1. Open the empty project where you will use AngularJS.
  2. Install Bower as described in Bower.
  3. Open the embedded Terminal (View | Tool Windows | Terminal or Alt+F12) and type bower install angular at the command prompt to install the package as a project dependency.

Starting with an existing AngularJS application

If you already have Angular 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 a JavaScript library.

To check out the application sources from your version control

  1. Click Check out from Version Control on the Welcome screen or choose VCS | Check out from Version Control on the main menu.
  2. Select your version control system from the list.
  3. In the VCS-specific dialog that opens, type your credentials and the repository to check out the application sources from.

To download the dependencies

  • Click Run 'npm install' in the pop-up window:
    ws_npm_yarn_package_run_npm_install.png

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 Diagrams | Show AngularJS ui-router State Diagram 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.
Last modified: 18 June 2018

See Also