Posts

Showing posts from December, 2020

Understand NgModule in 15 mins | by Bytecode Pandit

Image
NgModule is really a very important concept of angular. And it helps to wire-up some important information for the compiler during run time. They are specially used for organizing the code into features, lazy loading routes, and creating reusable libraries. We're going to cover some important uses of NgModule with some examples. I assume you have some working knowledge of Angular. JavaScript Modules I want to clear that NgModules are completely different from modules in javascript (sometimes called ES6 module). They are simply a language construct that helps us to organize our code. For more information pls visit Javascript Modules Let's dive into NgModule, the AppModule. Let's start looking at a basic NgModule that exists in every Angular application i.e AppModule  import { BrowserModule } from '@angular/platform-browser' ; import { NgModule } from '@angular/core' ; import { AppComponent } from './app.component' ; @ NgModule ( { ...

Learn call, apply and bind in javascript | by Bytecode pandit

Image
Hi! Today I'll talk about the important topic call, apply, and bind. These javascript methods allow us to change the value of this  for a given function. And I will try to make these concepts as simple as that with appropriate examples. Function.prototype.call() The method invokes the function and allows us to one by one using commas.  var testArgument = { firstName : "John" , lastName : "Smith" , age : 24 , profession : "Developer" }; function testFunction ( text ) { console . log ( "value of this" , this ); console . log ( "value of text" , text ); } testFunction . call ( testArgument , "hello" ); // output /* value of this {firstName: "John", lastName: "Smith", age: 24, profession: "Developer"} value of text hello */ you call also pass array or string var testArgument = "String" function testFunction ( text ) { console . log ( "value of thi...