Debug observable in Angular

Async pipe will automatically subscribe to observable. And json pipe will output all the data in json format.

{{ data$ | async | json }}

Resolve observable in Angular

<div *ngIf="user$ | async as user; else userEmpty">
  {{ }}
  {{ }}

<ng-template #userEmpty>
    User is empty

StackBlitz + Github + Angular

For example you have any github repo with Angular in it
You can execute this repo by accessing it via stackblitz like this:
It gives you file browser. All your changes reflect automatically.
This trick works with branches and commits too:{GH_USERNAME}/{REPO_NAME}/tree/{TAG|BRANCH|COMMIT}


Structural directives (second version is used if you need to skip the html tag):

<div *ngIf="hero" class="hero-wrap">{{hero}}</div>

Same as:

<ng-container *ngIf="hero">
    <div class="hero-wrap">{{hero}}</div>

Property binding (first version is preferred for better debugging):

<button [disabled]="isDisabled">Disabled Button</button>

Same as:

<button disabled="{{isDisabled}}">Disabled Button</button>


Angular Service - is a singleton object that gets instantiated only once during the lifetime of the application. Angular services contain methods that maintain the data throughout the life of the application. The main intent of the Angular services is organise and share business logic, models or data and functions with various components of the application.

Leave a Comment