@angular/cli
is the Angular Command-Line Interface (aka CLI), and @latest
suggests that the command should use the most recent stable version of the package.npx
to run the latest version of Angular CLI to create a new Angular project named angular-demo
, with inline styles, inline templates, and skipping the creation of tests.npx
is a command-line utility that comes with npm (Node Package Manager) and it's used to execute packages that are not globally installed in your system.-p @angular/cli
: the -p
option is used with npx command to specify the package to be executed.ng new [PROJECT_NAME]
: ng new
is a command from the Angular CLI that creates a new Angular workspace with an initial skeleton application-s -t -S
: these are flags used to customize how the Angular project is set up:
-s
: used to generate components that use inline CSS (instead of an external .css
file. We'll talk about CSS in the next chapter)-t
: the HTML template will be included in the TypeScript file, as an inline string, instead of a separated .html
file.-S
: avoid to generate test filesCSS
.
Anyway feel free to select Sass or Less in your future projects.Client Side
:ng new project-name
) using the parameters I have described in the previous recipe, several files and directories are generated in the root of your project.angular.json
: defines project settings, build options, file paths, and more.package.json
: lists the npm
packages required for your project and scripts for running, building, and testing your applicationpackage-lock.json
: ensures that the same versions of dependencies are installed every time the project is set up, providing consistency across different environments.tsconfig.json
: specifies the root files and compiler options required to compile the project. Helps TypeScript understand how to compile the code.tsconfig.app.json
: extends tsconfig.json with settings specific to the app's source files, excluding tests.tsconfig.spec.json
: extends tsconfig.json with settings specific to unit tests, ensuring they are compiled correctly..editorconfig
: helps maintain consistent coding styles across different editors and IDEs..gitignore
: ensures that specific files and folders (like node_modules
) are not tracked by version controlREADME.md
: contains information about your project, such as how to run, build, and test the application.src/
: The main directory where all your application code resides.node_modules/
: contains all the installed npm packages and it's populated when you run npm install
and includes all dependencies listed in the package.json
angular.json
file defines project settings, build options, file paths, and more.
It also helps manage configurations for different environments and build targets.-t -s -S
options at the beginning of the chapter?
These choices are saved in this file and you can change them at any timeapp-root
componentapp-root
component is the main, or root, component of an Angular application. It acts as the entry point for the application, where the initial rendering and bootstrap process begins.app-root
component is generated by default, serving as the parent container for the entire application.@Component
decorator is applied on the AppComponent
class and it configures the component with the required properties, that are called metadataselector: 'app-root'
, which means this component can be utilised in HTML using the <app-root></app-root>
tag.Hello Angular
text to display I love Angular
instead. Try it in the playground below.
Switch between "Editor | Preview | Both" using the tabbar in the footerapp.component.ts
:app.routes.ts
and app.config.ts
are two important configuration files typically found in the /src
directory. They play crucial roles in setting up the application's routing and configuration:app.routes.ts
is used to define the routing configuration for the Angular application. Routing allows you to navigate between different views or components based on the URL.app.config.ts
is used to centralize configuration settings for the Angular application. This can include settings for services, environment variables, or other global configurations.