<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: seshubabubatchu</title>
    <description>The latest articles on DEV Community by seshubabubatchu (@seshubabubatchu).</description>
    <link>https://dev.to/seshubabubatchu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F687191%2F0ae27500-94b3-4f47-9d0d-f126a9324965.png</url>
      <title>DEV Community: seshubabubatchu</title>
      <link>https://dev.to/seshubabubatchu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seshubabubatchu"/>
    <language>en</language>
    <item>
      <title>Angular Injection Context</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Wed, 21 May 2025 15:37:24 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-injection-context-4e35</link>
      <guid>https://dev.to/seshubabubatchu/angular-injection-context-4e35</guid>
      <description>&lt;p&gt;The injection context is related to the concept of Angular dependency injection&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the injection context?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is a runtime environment where Angular determines which instance of a dependency should be provided when something requests it&lt;/p&gt;

&lt;p&gt;It is a place where the dependent injection looks up and resolves the dependencies when requested by a component, directive, or service&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;inject Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With dependency injection, we use the constructors to inject the required service into a component, directive, or service&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;simple example of Dependency Injection&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(private http:HttpClient){}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This can be simplified using the latest inject method available in the latest versions of Angular&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;simple example of an inject function&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const http = inject(HttpClient);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Importance of Injection Context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we need any service to be injected anywhere inside the component or directive, the injection context plays a major role in resolving these dependencies&lt;/p&gt;

&lt;p&gt;In general, inside a service file, we will write&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Injectable(providedIn : 'root' )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And at the component level, we will write it in the providers array &lt;/p&gt;

&lt;p&gt;And in the latest Angular versions, we can use the inject method outside the constructor as well&lt;/p&gt;

&lt;p&gt;So, for all these injection contexts, ensure that the requested services are injected at the requested hierarchy only(i.e, component level, root level)&lt;/p&gt;

&lt;p&gt;If Angular cannot find the service, then it looks for its parent injectors until it finds a provider or throws an error. The injection context helps in navigating this hierarchy&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Availability of Injection context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The injection context is available in the constructors of components, services, and directives as well&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Demo{
    userService = inject(UserService); //Injection context available
    constructor(private http:HttpClient) //Injection context available
        {
           this.demoService = inject(DemoService); //Injection context available
        }
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is also available in the factory functions for providers&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;providers : [
    {
        provide: Some_Token,
        useFactory: () =&amp;gt; {
            const httpClient = inject(HttpClient) //Injection context available
            return new ClassName(httpClient);
        }
    }

]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Running the inject function outside the automatically provided contexts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can use the runInjectionContext method here&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {inject, EnvironmentInjector, runInjectionContext} from '@angular/core';

class Demo{
   constructor(private injector:EnvironmentInjector){}
   someMethod(){
       runInjectionContext(this.injector, ()=&amp;gt;{
           const myService = inject(MyService); //works here
       }
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Summary *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The injection context allows Angular dependency injection to function properly. It defines the scope where Angular can look up and provide the dependencies that are requested by components, services, and directives.&lt;/p&gt;

&lt;p&gt;Thankyou...&lt;br&gt;
Happy Coding...&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>angular</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Angular Signals</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Tue, 20 May 2025 13:29:00 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-signlas-597j</link>
      <guid>https://dev.to/seshubabubatchu/angular-signlas-597j</guid>
      <description>&lt;p&gt;Signal is a wrapper around a value, and the value can be of any type&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signals are of 2 types&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;writable signals&lt;/li&gt;
&lt;li&gt;read-only singles&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Writable signals&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Signal Creation:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;const count: WritableSignal - signal(0) //writable signal example, and here 0 is the initial value provided to the count&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting the value of the signal&lt;/strong&gt;&lt;br&gt;
We can set and modify the value of signals in 2 ways&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;set method&lt;/li&gt;
&lt;li&gt;update method
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count.set(20) // updated count value from 0 to 20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;count.update(prevValue =&amp;gt; prevValue+1) //update value, also have the previous value of the signal&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reading the value of the signal&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;count() // we can access by calling the name of the variable with ()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;read-only signals&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;These types of signals are created using the computed keyword&lt;br&gt;
For these types of signals, we cannot update the value by using &lt;strong&gt;set or update&lt;/strong&gt; methods, unlike writable signals&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;creation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const doubleCount  =  computed(() =&amp;gt; count() *2 )
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Reading the read-only signalValue&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;doubleCount()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we can see that doubleCount is dependent on the count signal value &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read-only signals are lazily evaluated&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This means, unless we use somewhere in the code doubleCount(), the value is not calculated &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Read-only signals memorize the values&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the doubleCount value depends on the count value, when we read doubleCount(), then the value is calculated and it is cached, and whenever we call doubleCount () again, the cached value is returned &lt;/p&gt;

&lt;p&gt;It recalculates the value when the count value is updated, and when we use the doublecount() somewhere in the code&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Computed signals' dependencies are dynamic *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;simple example here&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const showCount = signal(false);
const count = signal(0);
const conditionalCount = computed(() =&amp;gt; {
  if (showCount()) {
    return `The count is ${count()}.`;
  } else {
    return 'Nothing to see here!';
  }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Initially, the value of showcount is false, so the conditionalCount is dependent upon showCount only, but not on the count value&lt;/p&gt;

&lt;p&gt;So later on if we update the count value,e the conditionalCount will not be recalculated since it is not dependent upon the count value&lt;/p&gt;

&lt;p&gt;If we make the showCount as true and then call the conditionalCount, then the conditionalCount is dependent upon both the showCount and the count values as well, so now when the count updates and when we call the conditionalCount, then the value is recalculated&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signals with onPush&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Even if we make a component change detection strategy on push, and it contains the signal, when the value of the signal is changed, Angular automatically marks the component to ensure it gets updated the next time change detection runs. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Effects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Effects run when an associated signal value changes, similar to the computed signals; it also has a dynamic dependency and runs the effect when the dependent signal value changes&lt;/p&gt;

&lt;p&gt;An effect is run at least once, and when it runs, it tracks any signal reads and any change to the dependency will re-run the effect again&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case of effects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;to log some data when a signal value changes&lt;br&gt;
to set data in local storage when the signal value changes&lt;br&gt;
and some other use cases as per requirement&lt;/p&gt;

&lt;p&gt;An effect can be written or created only in an injection context&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Injection context&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let us know about the injection context here first. So, what is an injection context? &lt;/p&gt;

&lt;p&gt;This is a concept related to dependency injection, i.e... When we use the services in the component, directives, and pipes, by injecting a service using the constructor&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;simple example for dependency injection&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;constructor(private HTTP: HttpClient){}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From Angular v14 onwards, we can use the inject keyword instead of the constructor as well&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private HTTP = inject(HtppClient)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, what is an injection context? It is an Angular runtime context that is used for dependency injection. It means we can run the dependency injection in only the injection context available&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When is the injection context available&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;When initializing components, directives, and pipes, (constructor method)&lt;/li&gt;
&lt;li&gt;Class field initialization&lt;/li&gt;
&lt;li&gt;In the useFactory method&lt;/li&gt;
&lt;li&gt;It is also available in AuthGuards directly&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;destroying the effects&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In general, effects will be deleted automatically when associated components get destroyed&lt;/p&gt;

&lt;p&gt;We can manually destroy the effect .destroy() method&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Untracked keyword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can prevent a signal read from being tracked by calling its getter with untracked:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;effect(() =&amp;gt; {
  console.log(`User set to ${currentUser()} and the counter is ${counter()}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above effect runs for both the signals, currentUSer and counter, as well&lt;/p&gt;

&lt;p&gt;If we need the counter signal changes not to trigger this effect, then we can use something like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;effect(() =&amp;gt; {
  console.log(`User set to ${currentUser()} and the counter is ${untracked(counter)}`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Untracked is also useful when an effect needs to invoke some external code, which shouldn't be treated as a dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;effect(() =&amp;gt; {
  const user = currentUser();
  untracked(() =&amp;gt; {
    this.loggingService.log(`User set to ${user}`);
  });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writable Signals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creation - const count = signal(initialValue)&lt;/li&gt;
&lt;li&gt;Read Signal - count()&lt;/li&gt;
&lt;li&gt;Change Value - count.set(newValue)&lt;/li&gt;
&lt;li&gt;Update Value - count.update(oldValue =&amp;gt; oldValue + 1)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Read only signals&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creation - const doubleCount = computed(() =&amp;gt; count() *2)&lt;/li&gt;
&lt;li&gt;Read Signal - doubleCount()&lt;/li&gt;
&lt;li&gt;These are read-only&lt;/li&gt;
&lt;li&gt;No set and update method works&lt;/li&gt;
&lt;li&gt;Consists of  Dynamic dependencies&lt;/li&gt;
&lt;li&gt;Lazily Evaluated&lt;/li&gt;
&lt;li&gt;Values are memorized&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Effects&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Consists of  Dynamic dependencies&lt;/li&gt;
&lt;li&gt;Effect runs at least once&lt;/li&gt;
&lt;li&gt;Runs every time a dependency signal value changes&lt;/li&gt;
&lt;li&gt;Concept of Injection context

&lt;ul&gt;
&lt;li&gt;Concept of dependency injection&lt;/li&gt;
&lt;li&gt;Availability of Injection context&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;destroying effects manually using the  .destroy method&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;Thanks........&lt;br&gt;
Happy Coding.....&lt;/p&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Learn Spring Data JPA, Part - 1</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Fri, 27 Dec 2024 10:03:17 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/learn-spring-data-jpa-part-1-2c2g</link>
      <guid>https://dev.to/seshubabubatchu/learn-spring-data-jpa-part-1-2c2g</guid>
      <description>&lt;h2&gt;
  
  
  Project Setup
&lt;/h2&gt;

&lt;p&gt;create a project using &lt;a href="https://start.spring.io/" rel="noopener noreferrer"&gt;https://start.spring.io/&lt;/a&gt; and add the following dependencies &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5hgqdeinvdtbxunz526.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd5hgqdeinvdtbxunz526.png" alt="screenshot of start.spring.io with needed dependencies" width="800" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Spring Data JPA - used to interact with relational databases. It simplifies data access and manipulation by leveraging the Java Persistence API (JPA)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Postgres SQL Driver - to Interact with the Postgres Database&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lombok - It Simplifies the code by using the pre-built annotation &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spring web - spring web for building web applications, particularly RESTful APIs. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;click on generate and open the folder in any of your favorite editors, we will be using the vs code here&lt;/p&gt;

&lt;p&gt;download the PostgreSQL for your respective OS and go through the installation steps, we will get the PGAdmin application on our machine&lt;/p&gt;

&lt;p&gt;open the PGAdmin application and create a database with any name you want&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7byk4spmkwbndb4zplau.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7byk4spmkwbndb4zplau.png" alt="image of postgres sql" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;now navigate to the vs code&lt;/p&gt;

&lt;p&gt;we will be renaming the application.properties file to application.yml here&lt;/p&gt;

&lt;p&gt;enter the following into the application.yml file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f77ikt1sxk5coobz8ts.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6f77ikt1sxk5coobz8ts.png" alt="application.yml" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ddl-auto :
here we will have basically 5 options&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;none: Disables schema generation. Your application will not attempt to create, drop, or validate the schema in any way.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;validate: Validates the schema with the database. It checks that the database schema matches the entities defined in your application. If there are discrepancies, an exception is thrown and the application won't start.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;update: Updates the database schema. It makes incremental changes to the database schema without dropping existing data. This is useful during development but may not be suitable for production environments as it might not handle complex schema changes gracefully.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create: Creates the schema every time the application starts. All existing data is removed and tables are created from scratch. This option is useful for testing but should be avoided in production.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;create-drop: Creates the schema when the application starts and drops the schema when the application stops. This is primarily used for integration tests where the schema needs to be set up and torn down for each test.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;here we are using the create-drop because since we are learning we will be making many changes so create-drop suits this requirement&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we are just specifying the URL, which would be our localhost, by default postgress runs on port 5432 so we are using the same port number followed by the database name&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;username and password which we set during the time of installation of postgress in our machines&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;show-sql means we can see the SQL commands that are used in the background in the terminal&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;make sure to follow the indentation and spaces correctly otherwise, this will not work&lt;/p&gt;

&lt;p&gt;if you do not wish to rename the application.properties to application.yml&lt;/p&gt;

&lt;p&gt;we can write like this as well&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tl8x8iy26cbo7toft0u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2tl8x8iy26cbo7toft0u.png" alt="application.properties" width="800" height="347"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is completely user-specific any approach works here we will be following the application.yml approach here&lt;/p&gt;

&lt;p&gt;Now run the Java program &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9shucsl62gx1l4xjz3g5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9shucsl62gx1l4xjz3g5.png" alt="running the java program" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can also run the program by right-clicking on the Java file and selecting Run Java.&lt;/p&gt;

&lt;p&gt;If your terminal does not have any errors, congratulations you have configured the initial project setup 🎉🥳🎉&lt;/p&gt;

</description>
      <category>java</category>
      <category>spring</category>
      <category>jpa</category>
      <category>backend</category>
    </item>
    <item>
      <title>Angular Services</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Sun, 05 Jun 2022 02:47:34 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-services-2gcl</link>
      <guid>https://dev.to/seshubabubatchu/angular-services-2gcl</guid>
      <description>&lt;p&gt;Services are nothing but classes with a particular function for example fetching or providing data to other componenets&lt;br&gt;
Dependency Injection &lt;br&gt;
Dependency injection is nothing but using the services in other components with loosely coupled so that changes can be easily made&lt;br&gt;
DI conists of mainly 5 modules&lt;br&gt;
consumerrs&lt;br&gt;
prodivders&lt;br&gt;
di token&lt;br&gt;
depeendency&lt;br&gt;
injector&lt;br&gt;
It is responsibility of injector to provide and resolve the services and dependencies to the requested components&lt;br&gt;
we register the service using providers array either at module level or at component level &lt;br&gt;
di token is an unique identification token with which injector identofies the serive and provides the instance of service to requested components&lt;br&gt;
dependency is the service&lt;br&gt;
consumers are nothing but componenets or directives or pipes which requires the service &lt;br&gt;
Asking for service in a component using DI&lt;br&gt;
constructor(private productSercie:ProductService){}&lt;br&gt;
we use @Injectable() if we need other service, if any other decorator is already exising in class then we dont need @Injectable() decorator we simply can use the above constructor syntax &lt;br&gt;
Injecting service into another service&lt;br&gt;
@Injectable() is used for consistency purpose in every service but in general we do not need if the service do not require any other service as dependency&lt;br&gt;
for registering a service there is no option to add providers in service class the provider must be added either in module level or component level&lt;br&gt;
So the service can be added to providers array in app.component.ts&lt;br&gt;
Now the providers array is in app.component then the services are available only to app component and its child components, to make the services availalbe globally then we must move this providers array to @NgModule decorator&lt;/p&gt;

&lt;p&gt;instead of adding to ngModele providedIn can be used providedIn:'root'&lt;/p&gt;

&lt;p&gt;angular Injector &lt;br&gt;
ModuleInjector - rootModuleInjector - created when bootstraps the application this becomes part of moduleInjector - appModule get its own injector called rootModuleInjector&lt;/p&gt;

&lt;p&gt;for every component have their own injector instance and providers array&lt;br&gt;
ElementInjector -  for elements (components and directives)&lt;/p&gt;

&lt;p&gt;@Inject -  this can be used as an alternatie for @Injectable()&lt;br&gt;
@Inject takes injector token as parameter&lt;br&gt;
@Inject(LoggerService) private loggerService&lt;/p&gt;

&lt;p&gt;angular Providers&lt;br&gt;
angular providers helps us to register classes, functions or values with a token&lt;/p&gt;

&lt;p&gt;4ways of creating a dependecy&lt;br&gt;
useClass&lt;br&gt;
useValue&lt;br&gt;
useFactory&lt;br&gt;
useExisting&lt;/p&gt;

&lt;p&gt;angular providers is an array of instructions &lt;/p&gt;

&lt;p&gt;providers: [ProductService] this is shorthand notation for providers :[{ provide: ProductService, useClass: ProductService }] this&lt;br&gt;
where provide - is a token and can be type,string or instance of InjctionToken&lt;br&gt;
where second one -  It tells Angular how to create the instance of the dependency. The Angular can create the instance of the dependency in four different ways. It can create a dependency from the existing service class (useClass). It can inject a value, array, or object (useValue). It can use a factory function, which returns the instance of service class or value (useFactory). It can return the instance from an already existing token (useExisting).&lt;br&gt;
string type&lt;br&gt;
{provide:'PRODUCT_SERVICE', useClass: ProductService }, &lt;br&gt;
 {provide:'USE_FAKE', useValue: true },&lt;br&gt;&lt;br&gt;
 {provide:'APIURL', useValue: '&lt;a href="http://SomeEndPoint.com/api"&gt;http://SomeEndPoint.com/api&lt;/a&gt;' },&lt;br&gt;
@Inject('PRODUCTSERVICE') private prdService:ProductService,&lt;br&gt;
Injection token type&lt;/p&gt;

&lt;p&gt;export const API_URL= new InjectionToken(''); &lt;/p&gt;

&lt;p&gt;providers: [ &lt;br&gt;
    { provide: API_URL, useValue: '&lt;a href="http://SomeEndPoint.com/api"&gt;http://SomeEndPoint.com/api&lt;/a&gt;' }&lt;br&gt;
]PI_URL, useValue: '&lt;a href="http://SomeEndPoint.com/api"&gt;http://SomeEndPoint.com/api&lt;/a&gt;' }&lt;br&gt;
]&lt;br&gt;
constructor(@Inject(API_URL) private apiURL: string) { &lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;@optional - skips import of service if service not there instead of throwing error&lt;br&gt;
@self -  only checks providers array of its component only if not found throws error&lt;br&gt;
@skipSelf() - skips component providers and search for top level&lt;br&gt;
@Host - limits the search to template only it does not even search in component ts file also&lt;br&gt;
for example &lt;/p&gt;

&lt;p&gt;import service in providers array of directiveName and use the directive in component html&lt;br&gt;
it looks for service in current component providers and also looks for dependency in template level in host component&lt;br&gt;
Add the RandomService to the Providers of the GrandChildComponent. Because that is where DI looks first for dependency.&lt;/p&gt;

&lt;p&gt;The second option is to add RandomService to viewProviders array of the ChildComponent.&lt;/p&gt;

&lt;p&gt;providedIn - root&lt;br&gt;
providedIn - moduleName&lt;br&gt;
providersArray[] - ngModule&lt;br&gt;
providedIn - any&lt;br&gt;
providedIn - platform&lt;/p&gt;

&lt;p&gt;concept of treeShaking&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>angular</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Angular set and patch value in Template driven forms</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Tue, 19 Apr 2022 06:46:08 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-set-and-patch-value-in-template-driven-forms-2ale</link>
      <guid>https://dev.to/seshubabubatchu/angular-set-and-patch-value-in-template-driven-forms-2ale</guid>
      <description>&lt;p&gt;Hey Guys!!!&lt;br&gt;
I was going through angular forms and found a topic quite confusing have gone through a lot of youtube tutorials which are different from another, every one explains in their own way &lt;br&gt;
So decided to make a post on this in-depth.&lt;br&gt;
we are going to see in how many ways set and patch value can be used in angular *&lt;em&gt;template-driven forms *&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;and common errors that I have encountered while setting and patching values in angular forms &lt;/p&gt;

&lt;p&gt;Straight into code &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--81qUB7_E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo8xi9nopfty0jxrrx5s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--81qUB7_E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo8xi9nopfty0jxrrx5s.png" alt="Image description" width="880" height="374"&gt;&lt;/a&gt;&lt;br&gt;
This is the template-driven form we are going to use in this blog&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XvYC8AO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gca19do04nrz638mgat.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XvYC8AO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gca19do04nrz638mgat.png" alt="Image description" width="671" height="725"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yXnF0cju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sruhlnb9mqi2angwwygq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yXnF0cju--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sruhlnb9mqi2angwwygq.png" alt="Image description" width="683" height="942"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s----qujTGO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc6stkwycsvfokkrymev.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s----qujTGO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xc6stkwycsvfokkrymev.png" alt="Image description" width="676" height="227"&gt;&lt;/a&gt;&lt;br&gt;
So one common error I was getting while setting and patching values without using any buttons and onclick events I mean when setting or patching values at the time on initialization in ngOnInit()&lt;br&gt;
is&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pgNP5eqD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/derg9lrqdx5nuetndsld.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pgNP5eqD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/derg9lrqdx5nuetndsld.png" alt="Image description" width="581" height="195"&gt;&lt;/a&gt;&lt;br&gt;
This error is quite annoying since there is no relevant info on the internet (maybe i did not search that great) &lt;br&gt;
So to avoid this it is quite simple to use a setTimeOut function while setting or patching values and call that function on ngOnInit() this works perfectly fine&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T22s7v1I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0h91nwsjkj9p4mf7lnwz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T22s7v1I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0h91nwsjkj9p4mf7lnwz.png" alt="Image description" width="537" height="744"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Ways to set and patch values :
&lt;/h2&gt;

&lt;p&gt;There are many ways to set and patch values you can use them according to your convinience, all the methods can be found in the above screenshot which were commented &lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Angular Routing #4</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Thu, 14 Apr 2022 05:45:24 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-routing-4-6l6</link>
      <guid>https://dev.to/seshubabubatchu/angular-routing-4-6l6</guid>
      <description>&lt;h2&gt;
  
  
  Angular Route Guards
&lt;/h2&gt;

&lt;p&gt;We use the Angular Guards to control, whether the user can navigate to or away from the current route.&lt;/p&gt;

&lt;p&gt;Uses of  Angular Route Guards&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To Confirm the navigational operation&lt;/li&gt;
&lt;li&gt;Asking whether to save before moving away from a view&lt;/li&gt;
&lt;li&gt;Allow access to certain parts of the application to specific users&lt;/li&gt;
&lt;li&gt;Validating the route parameters before navigating to the route&lt;/li&gt;
&lt;li&gt;Fetching some data before you display the component.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Types of Route Guards&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CanActivate - If a Route can be accessed or not?&lt;/li&gt;
&lt;li&gt;CanDeactivate - If Current Route can be leaved or not?&lt;/li&gt;
&lt;li&gt;Resolve - Load or perform some operations before entering Route&lt;/li&gt;
&lt;li&gt;CanLoad - This guard works similar to CanActivate guard with one difference. The CanActivate guard prevents a particular route being accessed. The CanLoad prevents entire lazy loaded module from being downloaded, Hence protecting all the routes within that module.&lt;/li&gt;
&lt;li&gt;CanActivateChild - This guard determines whether a child route can be activated. This guard is very similar to CanActivateGuard. We apply this guard to the parent route. The Angular invokes this guard whenever the user tries to navigate to any of its child route.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Implementing RouteGuards
&lt;/h2&gt;

&lt;p&gt;import { Injectable } from '@angular/core';&lt;br&gt;
import { Router, CanActivate, ActivatedRouteSnapshot,RouterStateSnapshot } from '@angular/router';&lt;/p&gt;

&lt;p&gt;@Injectable()&lt;br&gt;
`export class ProductGuardService implements CanActivate {&lt;/p&gt;

&lt;p&gt;constructor(private _router:Router ) {&lt;br&gt;&lt;br&gt;
  }      &lt;/p&gt;

&lt;p&gt;canActivate(route: ActivatedRouteSnapshot,&lt;br&gt;
              state: RouterStateSnapshot): boolean {&lt;br&gt;
      console.log("canActivate");      //return true&lt;br&gt;&lt;br&gt;
     //remove comments to return true&lt;br&gt;&lt;br&gt;
     alert('You are not allowed to view this page. You are redirected to Home Page'); &lt;br&gt;
     this._router.navigate(["home"]);&lt;br&gt;&lt;br&gt;
     return false;&lt;br&gt;&lt;br&gt;
} }`&lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>uiweekly</category>
    </item>
    <item>
      <title>Angular Routing #3</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Thu, 14 Apr 2022 04:03:52 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-routing-3-360c</link>
      <guid>https://dev.to/seshubabubatchu/angular-routing-3-360c</guid>
      <description>&lt;h2&gt;
  
  
  Query Params:
&lt;/h2&gt;

&lt;p&gt;Simple example &lt;br&gt;
&lt;code&gt;&amp;lt;a [routerLink]="['product']" [queryParams]="{ page:2 }"&amp;gt;Page 2&amp;lt;/a&amp;gt;&lt;br&gt;
The router will construct the URL as /product?pageNum=2&lt;br&gt;
&amp;lt;a [routerLink]="['product']" [queryParams]="{ val1:2 , val2:10}"&amp;gt;Whatever&amp;lt;/a&amp;gt;&lt;br&gt;
The router will construct the URL as /product?val1=2&amp;amp;val2=10&lt;br&gt;
Programatically also we can pass queryparams&lt;br&gt;
  this.router.navigate(['/product'], { queryParams: { page: pageNum } });&lt;/code&gt;&lt;br&gt;
here router is of type Router &lt;/p&gt;

&lt;p&gt;&lt;code&gt;import { Router } from '@angular/router';&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Reading QueryParams
&lt;/h2&gt;

&lt;p&gt;this.sub = this.Activatedroute.queryParamMap&lt;br&gt;
       .subscribe(params =&amp;gt; {&lt;br&gt;
     this.pageNum = +params.get('pageNum')||0;&lt;br&gt;&lt;br&gt;
});&lt;br&gt;
this.Activatedroute.snapshot.queryParamMap.get('pageNum')||0&lt;/p&gt;

&lt;p&gt;why snapshot and subscribe and what is difference between them&lt;/p&gt;

&lt;p&gt;Remember, the router populates the snapshot, when the component loads for the first time. Hence you will read only the initial value of the query parameter with the snapshot property. You will not be able to retrieve any subsequent changes to the query parameter.&lt;/p&gt;

&lt;h2&gt;
  
  
  query Params Handling
&lt;/h2&gt;

&lt;p&gt;We have three options to handle these query params they are &lt;br&gt;
Preserve - The Angular preserves or carry forwards the query parameter of the current route to next navigation. Any query parameters of the next route are discarded&lt;br&gt;
Merge - The Angular merges the query parameters from the current route with that of next route before navigating to the next route.&lt;br&gt;
Null - This is default option. The angular removes the query parameter from the URL, when navigating to the next..&lt;/p&gt;

&lt;p&gt;Navigate between Routes&lt;br&gt;
We are having 2 ways to navigate Around different routes&lt;br&gt;
Which is one by &lt;a&gt;&lt;/a&gt;&lt;br&gt;
and other would be programatic navigation&lt;br&gt;
this._router.navigate(['product/detail/1']&lt;br&gt;
this._router.navigateByUrl('product')&lt;br&gt;
this._router.navigate(['detail'], { queryParams: { pageNum: this.pageNum + 1 }, relativeTo: this._Activatedroute } );&lt;br&gt;
.navigate or .navigateByurl both always uses absolute path &lt;br&gt;
So what is difference between absolute and relative path&lt;br&gt;
absolute contains a / before route like /about&lt;br&gt;
absolute path always appends to the base url like in our case locally it would be &lt;br&gt;
localhost:4000/about&lt;br&gt;
Relative path does not contain a / before it appends the url to currently activates route&lt;br&gt;
if you are in page localhost:4000/career then it would append to this as localhost:4000/career/about&lt;/p&gt;

&lt;p&gt;Folder Structure &lt;br&gt;
./ ../ .../ these type of routes can also be used these comes under relative paths and not as absolute paths &lt;br&gt;
this would navigate like&lt;br&gt;
./ - appends given route one level up &lt;br&gt;
../ - appends given route 2 level up&lt;br&gt;
example : &lt;br&gt;
active route is - localhost:4200/about&lt;br&gt;
./home - localhost:4200/about/home&lt;br&gt;
../home - localhost:4200/home &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>angular</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Angular Routing #2</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Tue, 12 Apr 2022 06:11:23 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-routing-2-a76</link>
      <guid>https://dev.to/seshubabubatchu/angular-routing-2-a76</guid>
      <description>&lt;p&gt;Route Params&lt;br&gt;
Ex:&lt;br&gt;
&lt;code&gt;{ path: 'product/:id/, component: ProductDetailComponent }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;a [routerLink]="['/Product', product.productID]"&amp;gt;{{product.name}} &amp;lt;/a&amp;gt;&lt;/code&gt;&lt;br&gt;
Retriving Params:&lt;br&gt;
ActivatedRoute can be used for this purpose&lt;br&gt;
this.id=this._Activatedroute.snapshot.paramMap.get("id");&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this._Activatedroute.paramMap.subscribe(params =&amp;gt; { &lt;br&gt;
    this.id = params.get('id'); &lt;br&gt;
});&lt;/code&gt;&lt;br&gt;
We usually retrieve the value of the parameter in the ngOninit life cycle hook, when the component initialised.&lt;/p&gt;

&lt;p&gt;When the user navigates to the component again, the Angular does not create the new component but reuses the existing instance. In such circumstances, the ngOnInit method of the component is not called again. Hence you need a way to get the value of the parameter.&lt;/p&gt;

&lt;p&gt;By subscribing to the observable paramMap property, you will retrieve the latest value of the parameter and update the component accordingly.&lt;br&gt;
can also get the parent params like&lt;/p&gt;

&lt;p&gt;&lt;code&gt;this.sub=this._Activatedroute.parent.params.subscribe(params =&amp;gt; { &lt;br&gt;
          this.id = params['id']; &lt;br&gt;
          let products=this._productService.getProducts();&lt;br&gt;
          this.product=products.find(p =&amp;gt; p.productID==this.id);    &lt;br&gt;
      });&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Simple code snippet:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PaRpcqta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxbyohdnsmrutbs4sq2h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PaRpcqta--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zxbyohdnsmrutbs4sq2h.png" alt="Image description" width="615" height="598"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>angular</category>
      <category>typescript</category>
    </item>
    <item>
      <title>Angular Routing #1</title>
      <dc:creator>seshubabubatchu</dc:creator>
      <pubDate>Tue, 12 Apr 2022 05:07:40 +0000</pubDate>
      <link>https://dev.to/seshubabubatchu/angular-routing-1kbg</link>
      <guid>https://dev.to/seshubabubatchu/angular-routing-1kbg</guid>
      <description>&lt;h2&gt;
  
  
  Location Stratagies
&lt;/h2&gt;

&lt;p&gt;Angular supports two Location Strategies:&lt;/p&gt;

&lt;h2&gt;
  
  
  HashLocationStrategy
&lt;/h2&gt;

&lt;p&gt;Where URL looks like &lt;a href="http://localhost:4200/#/product"&gt;http://localhost:4200/#/product&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  PathLocationStrategy
&lt;/h2&gt;

&lt;p&gt;Where URL looks like &lt;a href="http://localhost:4200/product"&gt;http://localhost:4200/product&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Server Side Routing
&lt;/h2&gt;

&lt;p&gt;General behaviour of web application is it sends every request to the server for loading of each and every request&lt;/p&gt;

&lt;h2&gt;
  
  
  Client side routing
&lt;/h2&gt;

&lt;p&gt;As angular handles all the routing part without sending each and every request to the server there are also some cons associated with this approach&lt;br&gt;
You won’t be able to refresh the page&lt;br&gt;
You won’t be able to go to a particular view by typing the URL&lt;br&gt;
Sharing the URL with someone is not possible&lt;br&gt;
The Back button will not work as you cannot go back to the previous page&lt;br&gt;
SEO is not possible&lt;/p&gt;

&lt;p&gt;The Client-side routing simply mimics server-side routing by running the process in the browser. It changes the URL in the browser address bar and updates the browser history, without actually sending the request to the server&lt;/p&gt;

&lt;p&gt;The Client-side routing is handled in two ways&lt;/p&gt;

&lt;p&gt;Hash style Routing&lt;br&gt;
HTML 5 Routing(path Location)&lt;/p&gt;

&lt;h2&gt;
  
  
  Hash Style :
&lt;/h2&gt;

&lt;p&gt;It user a tag #'es to achieve this&lt;br&gt;
&lt;a href="http://www.example.com"&gt;http://www.example.com&lt;/a&gt;&lt;br&gt;
&lt;a href="http://www.example.com/#/about"&gt;http://www.example.com/#/about&lt;/a&gt;&lt;br&gt;
&lt;a href="http://www.example.com/#/contact"&gt;http://www.example.com/#/contact&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML 5 Routing :
&lt;/h2&gt;

&lt;p&gt;Using history.pushState() method, we can now programmatically add the browser history entries and change the location without triggering a server page request.&lt;/p&gt;

&lt;p&gt;The history.pushState method accepts the following three parameters.&lt;/p&gt;

&lt;p&gt;State object: A state object is a JavaScript object which is associated with the new history entry created by pushState()&lt;br&gt;
Title: This is an optional title for the state&lt;br&gt;
URL: The new history entry’s URL. The browser won’t jump to that page.&lt;/p&gt;

&lt;p&gt;var stateObj= { message: "some message" };&lt;br&gt;
history.pushState(stateObj, "title", newUrl);&lt;/p&gt;

&lt;p&gt;When you request for &lt;a href="http://www.example.com"&gt;http://www.example.com&lt;/a&gt; the server sends the index.html&lt;/p&gt;

&lt;p&gt;Now, When you click on ProductList link, Angular use’s the history.pushState method to push the state and change the URL to &lt;a href="http://www.example.com/ProductList"&gt;http://www.example.com/ProductList&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, when you click on the specific Product, we again the use history method to push the state and change the URL to &lt;a href="http://www.example.com/product/1"&gt;http://www.example.com/product/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, when you click the back button, the browser will retrieve the &lt;a href="http://www.example.com/ProductList"&gt;http://www.example.com/ProductList&lt;/a&gt; from history and displays it.&lt;/p&gt;

&lt;p&gt;But there are cons to this approach&lt;/p&gt;

&lt;p&gt;Not all browsers support HTML 5&lt;br&gt;
The older browser does not support HTML5. So if you want to support older browser, you have to stick to the hash style routing&lt;br&gt;
The server support is needed for HTML5 based routing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Path Location Stratagey
&lt;/h2&gt;

&lt;p&gt;The PathLocationStrategy is the default strategy in Angular application.&lt;/p&gt;

&lt;p&gt;To Configure the strategy, we need to add  in the &lt;/p&gt; section of root page (index.html) of our application



&lt;p&gt;The Browser uses this element to construct the relative URLs for static resources (images, CSS, scripts) contained in the document.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hash Location Strategy
&lt;/h2&gt;

&lt;p&gt;You can use the HashLocationStrategy by providing the useHash: true in an object as the second argument of the RouterModule.forRoot in the AppModule.&lt;br&gt;
RouterModule.forRoot(appRoutes, { useHash: true })&lt;/p&gt;

&lt;h2&gt;
  
  
  Which Location Strategy to Use??
&lt;/h2&gt;

&lt;p&gt;use the HTML 5 style (PathLocationStrategy ) as your location strategy.&lt;br&gt;
It produces clean and SEO Friendly URLs that are easier for users to understand and remember.&lt;br&gt;
You can take advantage of the server-side rendering, which will make our application load faster, by rendering the pages in the server first before delivering it the client&lt;br&gt;
Use hash location strategy only if you have to support the older browsers.&lt;/p&gt;

&lt;p&gt;Hope this helps..&lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>javascript</category>
      <category>uiweekly</category>
    </item>
  </channel>
</rss>
