Categories
Uncategorized

Detecting Angular 5 Router State Changes

Detecting Route state changes can be done by subscribing to the router and listening to the events being emitted. In the example below you will see all the router events that you can listen to in Angular 5.

Categories
Uncategorized

Angular Material with Angular 5

Install the latest version of Angular Material + Animations using npm to get started.

Categories
interview

Javascript call() vs apply() vs bind()

call

The call() is a predefined Javascript function which can used to call a method of an object while passing it another object. For example, if you look at the following code, you will observe that the object being passed into the call() method replaces the this variable of the object whose method is being invoked.

Categories
Uncategorized

Testing Component with Service (Promise) in Angular 5

To perform unit testing on a component that makes use of a service, that returns a promise, we can use fakeAsync() and spy() methods from Angular’s unit testing package.

Categories
interview

Passing an object vs primitive data type in Js

In Javascript, when you pass a primitive data type like String or Int in Java to a function or a method, and a function modifies it, then this does not effect the actual data being passed. For example,