Questions tagged [angular]

Questions about Angular (not to be confused with AngularJS), the web framework from Google. Use this tag for Angular questions which are not specific to an individual version. For the older AngularJS (1.x) web framework, use the AngularJS tag.

The spiritual successor to the older AngularJS web framework.
(Questions about the older framework should use the tag instead.)

Features and Benefits


Building Blocks of Angular Apps

  • Module: A typical module is a cohesive block of code dedicated to a single purpose. A module exports something of value in that code, typically one thing such as a class.

  • Component: A component is a building block with component metadata. In TypeScript, we'd apply the @Component decorator to attach metadata to the class. This metadata mainly consists of the template or templateUrl, the selector, and the attached styling.

  • Template: We define a Component's view with its companion template. A template is a form of HTML that tells Angular how to render the Component.

  • Metadata: Metadata tells Angular how to process a class.

  • Data Binding: Angular supports data binding, a mechanism for coordinating parts of a template with parts of a component. There are four forms of data-binding syntax:

    • Interpolation: {{value}}
    • Property binding : [property]="value"
    • Event Binding : (event)="handler"
    • Two-way data binding: [(ngModel)]="property"
  • Service: "Service" is a broad category encompassing any value, function or feature that our application needs.

  • Directive: A directive is a class with directive metadata. In TypeScript, we'd apply the @Directive decorator to attach metadata to the class.

  • Dependency Injection: "Dependency Injection" is a way to supply a new instance of a class with the fully-formed dependencies it requires. Most dependencies are services. Angular uses dependency injection to provide new components with the services they need.

  • Pipes: Pipes are used for transforming values from one form to another. Angular offers many built-in pipes. Also, you can create custom pipes too.


See the changelog for latest version information.

As of Oct 2022, the current version is 14.2.0 See the full release schedule on the official GitHub repository. Angular versioning follows Semantic Versioning principles; all major versions feature some breaking changes over the previous ones.

Consider using the Update Guide for tips before changing the version.


Browser Support

  • Latest versions of Chrome, Edge, Firefox, IE, and Safari
  • Tested for older browsers including IE9+ and Android 4.1+

Useful links


Books


Code Editors & IDEs


Rich UI components for Angular


Cross-Platform Development


Related tags


Official Logo:

angular logo


Official Website:

angular.io


299281 questions
51
votes
13 answers

Disable Angular 5 Input fields correct way

I have a FormGroup that was created like that: form: FormGroup; constructor(private _formBuilder: FormBuilder) { } this.form = this._formBuilder.group({ name: ['', Validators.required], email: ['', Validators.required,…
João Ghignatti
  • 2,281
  • 1
  • 13
  • 25
51
votes
11 answers

The command "npm run build -- --prod" exited with code 1 error

I'm developing an Asp.Net Core 2 and Angular 5 project in visual studio 2017. When I'm going to publish my project then the error 'The command "npm run build -- --prod" exited with code 1' show in error list window. I created the project with…
Iman Bahrampour
  • 6,180
  • 2
  • 41
  • 64
51
votes
3 answers

Angular (5) httpclient observe and responseType: 'blob'

Context: I'm trying to download a binary file from a backend (that requires some data posted as json-body) and save it with file-saver using the filename specified by the backend in the content-disposition header. To access the headers I think I…
Chris
  • 1,508
  • 1
  • 11
  • 30
51
votes
10 answers

Cannot disable matInput element with [formControlName]

I'm using matInput and mat-form-field (@angular/material) in an Angular component, and I can't disable the matInput. A working example can be seen here. It seems likely that I'm missing something obvious, but for the life of me I can't figure out…
John
  • 9,249
  • 5
  • 44
  • 76
51
votes
3 answers

Angular 4/5 - route paramMap vs params

I am trying to get URL param in my Angular 5 app and I've found two ways of doing it: 1) Using paramMap ngOnInit() { this.hero$ = this.route.paramMap .switchMap((params: ParamMap) => …
Shota
  • 6,910
  • 9
  • 37
  • 67
51
votes
12 answers

How to disable a text area or mat-form-field

I am using Angular (4) + Angular Material and Reactive Forms for my Form Field. How can I disable that? I tried to google for things like disabled="true" or something like that. May can you show me the right syntax? That must be easy. Thanks! my…
dafna
  • 893
  • 2
  • 10
  • 21
51
votes
4 answers

Expected [ ] to be [ ] Jasmine, how to check empty array

Getting error while trying to check for empty array. I tried using: Case 1: By initializing as an array expect(fixture.componentInstance.dataSource).toBe([]); Case 2: By initializing as an array let expectedAry = new…
Kailas
  • 7,350
  • 3
  • 47
  • 63
51
votes
8 answers

How to cancel current request in interceptor - Angular 4

As you know it's possible to use Interceptors in new versions of Angular 4. In mine, I want to cancel a request in interceptor in some conditions. So is it possible? Maybe what I should ask is: which way I should do that? It'll also be OK if I find…
Behnam Azimi
  • 2,260
  • 3
  • 34
  • 52
51
votes
3 answers

What is the meaning of question mark in expressions in Angular 2?

What does values?.listArray mean here? Specifically I am interested in the question mark. [inputValue] = "values?.listArray"
crystal_test
  • 661
  • 1
  • 6
  • 20
51
votes
7 answers

How to rename an Angular project?

I renamed my Angular 4 project folder from auction-life to auction-05-life and replaced 3 occurrences of the old project name in: angular-cli.json Line 4 app.e2e-spec.ts Line 3 package.json Line 2 I then ran ng serve and got this: You seem to not…
Liwy
  • 511
  • 1
  • 4
  • 5
51
votes
13 answers

How to hide/delete underline input Angular Material?

I have input element in Angular Material: When input has focus it displays underline. How to hide or remove that? Seem I need to set null for underlineRef?
Daniel
  • 1,695
  • 6
  • 23
  • 41
51
votes
3 answers

Angular 4.3 Interceptor not working

I try to use new Angular 4.3 interceptors for setting authorithation header for all requests. However, it is not working. I set breakpoint into the interceptors intercept method and browser did not hit it, so it seems like angular just ignores my…
Kirill Ivanov
  • 517
  • 1
  • 4
  • 6
51
votes
7 answers

Making Sense of 'No Shadowed Variable' tslint Warning

I have a function that checks for the current stage in a sequential stream, based on a particular discipline that is passed in, and, according to that value, assigns the next value in my Angular 2 app. It looks something like this: private…
Rey
  • 1,393
  • 1
  • 15
  • 24
51
votes
2 answers

Angular CLI - Please add a @NgModule annotation when using latest

note: I'm new to Angular, so please excuse any new comer stupidity here. Details I've installed the latest version of Angular CLI The default app loads and runs perfectly fine after 'ng serve' Issue I decided to create a new module an import it…
MegaTron
  • 3,133
  • 6
  • 28
  • 45
51
votes
10 answers

How to use Material Design Icons In Angular 4?

I want to use the icons from https://materialdesignicons.com/ in my angular 4 project. The instructions on the website are only covering how to include it in Angular 1.x (https://materialdesignicons.com/getting-started) How can I include the…
Matthias Herrmann
  • 2,650
  • 5
  • 32
  • 66
1 2 3
99
100