This project was generated with Angular CLI version 7.2.1.
A work in progras based on this tutorial.
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
To debug the client side Angular code, we'll need to install the Debugger for Chrome extension.
Note: This tutorial assumes you have the Chrome browser installed. Microsoft also publishes a version of this extension for their Edge browser.
Open the Extensions view (kb(workbench.view.extensions)
) and type 'chrome` in the search box. You'll see several extensions which reference Chrome.
Press the Install button for Debugger for Chrome. The button will change to Installing then, after completing the installation, it will change to Reload. Press Reload to restart VS Code and activate the extension.
To set a breakpoint in app.component.ts
, click on the gutter to the left of the line numbers. This will set a breakpoint which will be visible as a red circle.
We need to initially configure the debugger. To do so, go to the Debug view (kb(workbench.view.debug)
) and click on the gear button to create a launch.json
debugger configuration file. Choose Chrome from the Select Environment drop-down list. This will create a launch.json
file in a new .vscode
folder in your project which includes a configuration to launch the website.
We need to make one change for our example: change the port of the url
from 8080
to 4200
. Your launch.json
should look like this:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
Press kb(workbench.action.debug.start)
or the green arrow to launch the debugger and open a new browser instance. The source code where the breakpoint is set runs on startup before the debugger was attached so we won't hit the breakpoint until we refresh the web page. Refresh the page and you should hit your breakpoint.
You can step through your source code (kb(workbench.action.debug.stepOver)
), inspect variables such as AppComponent
, and see the call stack of the client side Angular application.
The Debugger for Chrome extension README has lots of information on other configurations, working with sourcemaps, and troubleshooting. You can review it directly within VS Code from the Extensions view by clicking on the extension item and opening the Details view.
Run ng generate component component-name
to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module
.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.