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.

Filter by
Sorted by
Tagged with
1838votes
49answers
1.2mviews

Can't bind to 'ngModel' since it isn't a known property of 'input'

I've got the following error when launching my Angular app, even if the component is not displayed. I have to comment out the <input> so that my app works. zone.js:461 Unhandled Promise ...
user avatar
1716votes
31answers
685kviews

What is the difference between Promises and Observables?

What is the difference between Promise and Observable in Angular? An example on each would be helpful in understanding both the cases. In what scenario can we use each case?
user avatar
  • 17.2k
1347votes
27answers
681kviews

Difference between Constructor and ngOnInit

Angular provides life cycle hook ngOnInit by default. Why should ngOnInit be used, if we already have a constructor?
user avatar
  • 15.5k
1131votes
38answers
1.0mviews

Can't bind to 'formGroup' since it isn't a known property of 'form'

The situation I am trying to make what should be a very simple form in my Angular application, but no matter what, it never works. The Angular version Angular 2.0.0 RC5 The error Can't bind to '...
user avatar
1026votes
24answers
682kviews

Angular HTML binding

I am writing an Angular application and I have an HTML response I want to display. How do I do that? If I simply use the binding syntax {{myVal}} it encodes all HTML characters (of course). I need ...
user avatar
  • 30.7k
968votes
22answers
1.4mviews

Angular: conditional class with *ngClass

What is wrong with my Angular code? I am getting the following error: Cannot read property 'remove' of undefined at BrowserDomAdapter.removeClass <ol> <li *ngClass="{active: step==='...
user avatar
  • 31.5k
920votes
13answers
539kviews

BehaviorSubject vs Observable?

I'm looking into Angular RxJs patterns and I don't understand the difference between a BehaviorSubject and an Observable. From my understanding, a BehaviorSubject is a value that can change over time ...
user avatar
  • 9,273
918votes
26answers
299kviews

Angular/RxJS When should I unsubscribe from `Subscription`

When should I store the Subscription instances and invoke unsubscribe() during the ngOnDestroy life cycle and when can I simply ignore them? Saving all subscriptions introduces a lot of mess into ...
user avatar
841votes
19answers
997kviews

How can I use "*ngIf else"?

I'm using Angular and I want to use *ngIf else (available since version 4) in this example: <div *ngIf="isValid"> content here ... </div> <div *ngIf="!isValid">...
user avatar
818votes
45answers
1.4mviews

Could not find module "@angular-devkit/build-angular"

After updating to Angular 6.0.1, I get the following error on ng serve: Could not find module "@angular-devkit/build-angular" from "/home/Projects/myProjectName". Error: Could not find module "@...
user avatar
  • 15.7k
774votes
9answers
1.3mviews

ngFor with index as value in attribute

I have a simple ngFor loop which also keeps track of the current index. I want to store that index value in an attribute so I can print it. But I can't figure out how this works. I basically have ...
user avatar
  • 17.9k
712votes
16answers
477kviews

How to detect when an @Input() value changes in Angular?

I have a parent component (CategoryComponent), a child component (videoListComponent) and an ApiService. I have most of this working fine i.e. each component can access the json api and get its ...
user avatar
  • 9,923
701votes
21answers
751kviews

What is the equivalent of ngShow and ngHide in Angular 2+?

I have a number of elements that I want to be visible under certain conditions. In AngularJS I would write <div ng-show="myVar">stuff</div> How can I do this in Angular 2+?
user avatar
667votes
14answers
809kviews

How can I select an element in a component template?

Does anybody know how to get hold of an element defined in a component template? Polymer makes it really easy with the $ and $$. I was just wondering how to go about it in Angular. Take the example ...
user avatar
  • 7,265
651votes
38answers
847kviews

How to get current route

The current docs only talk about getting route params, not the actual route segments. For example, if i want to find the parent of current route, how is that possible?
user avatar
  • 39.4k

15 30 50 per page
1
2 3 4 5
18298