Posts

Showing posts from 2020

multi color initial(Avatars) if img not available in Angular it's work angular 2,4+ all versions

Image
Today I will show two methods apply background-color in initial Method 1: here I will show dynamic colors using random calls step 1: create a component and define color array list in .ts file public circleColor: string; colors = [ '#6930c3 ', // French Violet '#0096c7', // Blue green '#FFFF5C', // Laser lemon '#FF3366', // Radical red '#F49F0A', // Tagrine '#25a550', // Green '#03312E', // Rich black ]; step 2: ngOnInit() { const randomIndex = Math.floor(Math.random() * Math.floor(this.colors.length)); this.circleColor = this.colors[randomIndex]; } step 3: In .html <div class="circle" [ngStyle]="{'background-color': circleColor }"> // change color // <img *ngIf="!showInitials && showComponent" src="{{photoUrl}}" onerror="showInitials " class="initials">{{ initials }} ...

Refresh an Angular Component without reloading the same Component

Image
A short trick for refreshing data in the same Angular components. This snippet will work in Angular 2, 4, 5, 6, 7, 8, and 9. Here two method and  you can add according to your needs you are working with Angular and need to refresh a component without navigation on another component without  using   window.location.reload()    or   location.reload() ,  you can use the following code in your project: 1. using constructor in the same page(component) reload: any; Then, add this code to the required component's constructor . this . router . routeReuseStrategy . shouldReuseRoute = function () { return false ; }; this . mySubscription = this . router . events . subscribe (( event ) => { if ( event instanceof NavigationEnd ) { // Trick the Router into believing it's last link wasn't previously loaded this . router . navigated = false ;   } }); Make sure to ...

Basic git commands for every developers should know

If you're one of those developers who still don't use any version control system, I don't know how you're still managing to get all your work done. so now here I am providing some git commands and you can use also increase your knowledge and work proficiency. 1) git config Notes:  To set your user name and email in the main configuration file. How to use git commands:  To check your name and email type in  git config --global user.name  and  git config --global user.email . And to set your new email or name  git config --global user.name = “Bhuwan Paneru  and  git config --global user.email = “ bhuwanpaneru@yahoo.com ” 2) git init Notes:  To initialise a git repository for a new or existing project. How to   use git commands:   git init  in the root of your project directory. 3) git clone Notes:  To copy a git repository from a remote source, it also sets the remote to the original source so that you can...