Skip to content
Angular Essentials
GitHub

Let's get ready

Local development setup

Before we start building Angular app we need to set up the local environment and workspace from here.

Create a new Angular app!

ng new angular-basic --standalone

Configurations

  • Set no to Angular routing setup. We will do it manually.
  • Choose scss as stylesheet.

To give our app nice look install Angular Material.

ng add @angular/material

Introducing the app component

app/app.component.ts Defines the logic for the application’s root component, named AppComponent. The view associated with this root component becomes the root of the view hierarchy as you add components and services to your application.

app/app.component.html Defines the HTML template associated with the root AppComponent.

app/app.component.scss Defines the base CSS stylesheet for the root AppComponent.

app/app.component.spec.ts Defines a unit test for the root AppComponent.

Breaking down app.component.ts

@Component decorator that marks a class as an Angular component and provides configuration metadata that determines how the component should be processed, instantiated, and used at runtime.

templateUrl is the relative path or absolute URL of a template file for an Angular component. If provided, do not supply an inline template using the template.

styleUrls contains one or more relative paths or absolute URLs for files containing CSS stylesheets to use in this component.

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent { }

styles One or more inline CSS stylesheets to use in this component.

template An inline template for an Angular component. If provided, do not supply a template file using templateUrl.

@Component({
  selector: 'app-root',
  template: `
    <h1>Angular Basic</h1> <h2>Heading 2</h2>
  `,
  styles: ['h1 { font-weight: normal; }']
})
export class AppComponent { }

More on components.

Workspace configuration files

The top level of the workspace contains workspace-wide configuration files, configuration files for the root-level application, and subfolders for the root-level application source and test files.

.editorconfig Configuration for code editors.

.gitignore Specifies intentionally untracked files that Git should ignore.

README.md Introductory documentation for the root application.

angular.json CLI configuration defaults for all projects in the workspace, including configuration options for build, serve, and test tools that the CLI uses, such as Karma, and Protractor. For details, see Angular Workspace Configuration.

package.json Configures npm package dependencies that are available to all projects in the workspace. See npm documentation for the specific format and contents of this file.

package-lock.json Provides version information for all packages installed into node_modules by the npm client. See npm documentation for details. If you use the yarn client, this file will be yarn.lock instead.

src/ Source files for the root-level application project.

node_modules/ Provides npm packages to the entire workspace. Workspace-wide node_modules dependencies are visible to all projects.

tsconfig.json The base TypeScript configuration for projects in the workspace.

Application project files

The CLI command ng new app-name generated a new application skeleton in a src/ folder/

app/ Contains the component files in which your application logic and data are defined. See details below.

assets/ Contains image and other asset files to be copied as-is when you build your application.

environments/ Contains build configuration options for particular target environments. By default there is an unnamed standard development environment and a production (“prod”) environment. You can define additional target environment configurations.

favicon.ico An icon to use for this application in the bookmark bar.

index.html The main HTML page that is served when someone visits your site. The CLI automatically adds all JavaScript and CSS files when building your app.

main.ts The main entry point for your application. Compiles the application with the JIT compiler and bootstraps the application’s root module (AppModule) to run in the browser. You can also use the AOT compiler without changing any code by appending the —aot flag to the CLI build and serve commands.

polyfills.ts Provides polyfill scripts for browser support.

styles.sass Lists CSS files that supply styles for a project. The extension reflects the style preprocessor you have configured for the project.

test.ts The main entry point for your unit tests, with some Angular-specific configuration. You don’t typically need to edit this file.

Application configuration files

.browserslistrc Configures sharing of target browsers and Node.js versions among various front-end tools. See Browserslist on GitHub for more information.

karma.conf.js Application-specific Karma configuration.

tsconfig.app.json Application-specific TypeScript configuration, including TypeScript and Angular template compiler options. See TypeScript Configuration and Angular Compiler Options.

tsconfig.spec.json TypeScript configuration for the application tests. See TypeScript Configuration.