Angular is a popular framework for building cross-platform applications. JetBrains Rider provides support for Angular and helps you on every step of the development process – from creating a new Angular app and working on the components to debugging and testing it.
Before you start
To open an application that is organized in the directory structure and does not have a solution file, press Ctrl+O or choosefrom the main menu, and then specify the root folder of the application.
Running and debugging an Angular application
For applications created with Angular CLI , JetBrains Rider generates two run/debug configurations with default settings:
An npm configuration with the default name Angular CLI Server. This configuration runs the
ng servecommand that launches the development server and starts your application in the development mode.
Run an Angular application
Select the Angular CLI Server run configuration from the list on the toolbar and click next to the list.
npm startin the Terminal Ctrl+Alt+1 or double-click the
starttask in the npm tool window ( ).
Wait till the application is compiled and the Webpack development server is ready. Open your browser at http://localhost:4200/ to view the application.
When the development server is running, your application is automatically reloaded as soon as you change any of the source files and save the updates.
Debug an Angular application
Set the breakpoints in your code.
Start the application in the development mode as described above and wait till the application is compiled and the Webpack development server is ready.
To view the application, open your browser at the URL that is shown in the Run tool window, by default it is http://localhost:4200/.
If you are using another port or your application was not created with Angular CLI, copy the URL address at which your application is actually running, you will later specify this URL in a debug configuration.
If you created your application with Angular CLI and it is running on the default port
From the list of configurations, select the autogenerated Angular Application configuration or your newly created custom one and start a debugging session by clicking next to the list.
When the first breakpoint is hit, switch to the Debug window and proceed as usual: step through the program, stop and resume program execution, examine it when suspended, explore the call stack and variables, set watches, evaluate variables, view actual HTML DOM, and so on.
Navigating through an Angular application
Yet another way is the Related Symbol popup.
In an Angular component file, press F7 or select Related Symbol popup with a list of related files. In a TypeScript component file, the popup also lists all the symbols that were imported into this file.from the main menu or from the context menu. JetBrains Rider shows a
To open a file, select it and press Enter. Alternatively, use the numbers associated with each file type:
The TypeScript file with the component class
Adding new features to an Angular application using ng add
In projects that use Angular CLI 6 or later, you can use the Angular Dependency action to add new libraries. This action runs the
ng add command which installs the dependency and updates the app with a special installation script. Note that not all libraries support installation with
Select Project tool window, and then select Angular Dependency.from the main menu or press Ctrl+N in the
From the list, select the library to add. The list shows the libraries that can be definitely installed with
ng add. To install a package that is not on the list, scroll to its end and double-click the Install package not listed above link, then specify the package name in the dialog that opens.
The example below illustrates adding Angular Material to a project.
If you manage dependencies manually through your package.json, JetBrains Rider still recognizes packages that support
ng add. When you add such package to package.json, JetBrains Rider suggests installing it with
If such dependency is already installed, you may still want to reinstall it with
ng add. In the package.json file, select the name of the package, press Alt+Enter, and click Reinstall with ng add.
Inspecting Angular application code
JetBrains Rider brings a number of Angular-specific inspections that help you find errors as you edit your code and suggest quick-fixes for them.
In the example below, both a
template and a
templateUrl properties are used. JetBrains Rider detects the error, warns you about it, and suggests a quick-fix.
Another example shows how JetBrains Rider warns you about incorrect use of the
*ngFor structural directives.
View the list of Angular-specific inspections and configure them
In the Options dialog Ctrl+Alt+S, go to .
Expand the Angular node.
Configure inspection profiles and severity, disable and suppress predefined inspections, and create custom ones .
Using Angular Material Design components
JetBrains Rider recognizes Angular Material components and attributes and provides coding assistance for them:
Completion for components
Completion for attributes
Navigation between a component or an attribute and its declaration (press F12 or selectfrom the context menu).
Install Angular Material
In the embedded Terminal (Ctrl+Alt+1) , type:
ng add @angular/materialfor Angular CLI version 6 and later
npm install --save @angular/materialfor earlier versions of Angular CLI
Learn more from Getting Started on the Angular Material official website.
Configuring syntax highlighting
You can configure Angular-aware syntax highlighting according to your preferences and habits.
In the Options dialog Ctrl+Alt+S, go to .
Select the color scheme, accept the highlighting settings inherited from defaults or customize them as described in Configuring Colors and Fonts.