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 (can be subscribed to and subscribers can receive updated results). This seems to be the exact same purpose of an Observable. When would you … Read more

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===’step1′}” (click)=”step=’step1′”>Step1</li> <li *ngClass=”{active: step===’step2′}” (click)=”step=’step2′”>Step2</li> <li *ngClass=”{active: step===’step3′}” (click)=”step=’step3′”>Step3</li> </ol> 22 s 22 Angular version 2+ provides several ways to add classes conditionally: type one [class.my_class] = “step === ‘step1′” … Read more

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 ‘formGroup’ since it isn’t a known property of ‘form’ The code The view <form [formGroup]=”newTaskForm” (submit)=”createNewTask()”> <div class=”form-group”> <label … Read more

Difference between Constructor and ngOnInit

Angular provides life cycle hook ngOnInit by default. Why should ngOnInit be used, if we already have a constructor? 2 27 The Constructor is a default method of the class that is executed when the class is instantiated and ensures proper initialisation of fields in the class and its subclasses. Angular, or better Dependency Injector … Read more

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 rejection: Template parse errors: Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’. (” <div> <label>Created:</label> <input type=”text” [ERROR ->][(ngModel)]=”test” … Read more

Property ‘map’ Does Not Exist on Type ‘observable‘

You need to import the map operator: [php]import ‘rxjs/add/operator/map'[/php] Or more generally: [php]import ‘rxjs/Rx’;[/php] Notice: For versions of RxJS 6.x.x and above, you will have to use pipeable operators as shown in the code snippet below: [php]import { map } from ‘rxjs/operators’; import { HttpClient } from ‘@angular/common/http’; // … export class MyComponent { constructor(private http: HttpClient) … Read more