Angular Tutorial - 27 - Optional Route Parameters

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ธ.ค. 2024

ความคิดเห็น • 45

  • @CodingByAmp
    @CodingByAmp 4 ปีที่แล้ว +1

    the best of legend teaching angular .

  • @josemariacostateixeira6133
    @josemariacostateixeira6133 4 ปีที่แล้ว +2

    You are an excellent teacher!

  • @atharvasuryawanshi
    @atharvasuryawanshi ปีที่แล้ว

    Thank you for the Series. Great Videos!

  • @iyakfishing2917
    @iyakfishing2917 6 ปีที่แล้ว +6

    Great info!! Full of great practices!! But I've been using the routerLink to navigate back in pages which works fine, and easy but is this not good practice?

  • @MG-bm5oj
    @MG-bm5oj 6 ปีที่แล้ว +6

    Great videos!
    Just one question about this one. It doesn't seem a good practice to pass parameter back like shown in the video as the URL should be cleaned for SEO reasons so I wonder if there is another way to do it.
    Thanks for your time!

    • @0GRANATE0
      @0GRANATE0 6 ปีที่แล้ว

      Angular + SEO = horror

  • @abhig3871
    @abhig3871 6 ปีที่แล้ว +2

    Thank you for the Series.

  • @tharindu79
    @tharindu79 5 ปีที่แล้ว +4

    Why would you do a null check then assign null when it's null anyway?

    • @nasrihaithem9529
      @nasrihaithem9529 4 ปีที่แล้ว

      was going to ask same question lol

    • @sabaoonullahn4819
      @sabaoonullahn4819 3 ปีที่แล้ว

      @@nasrihaithem9529 I think that's because you can go with next to more than the ids that we have in the department list.

  • @another-day-2024
    @another-day-2024 4 ปีที่แล้ว +2

    @Codevolution : how to hide the optional parameters from url i.e. It does not look great to have ';id' in the URL.

  • @sonamohialdin3376
    @sonamohialdin3376 2 ปีที่แล้ว

    So good tutorial thank you

  • @juanjoseramirezcalderon2618
    @juanjoseramirezcalderon2618 5 ปีที่แล้ว +2

    Hi, I'm very new to Angular. Why are the URL params separated by a semicolon ( .../departments;id=2;test=testvalue ) ? I would expect it to be separated with commas and after a question mark (.../departments?id=2,test=testvalue). Is that the Angular way or something like that? Does it make a difference? Is it possible to use the question mark syntax way in the URL with Angular? I think there's something called , why is it not used here?

    • @sajansjoseph
      @sajansjoseph 5 ปีที่แล้ว

      First of all, its not comma, its & symbol used in normal URL (For server side languages)...
      Angular is not server side framework... all url requests are parsed and translated by local javascript engine. Hence Angular can accept anything in the URLs...
      Anyhow, semicolon is valid in URL...

  • @fabiotchezaum
    @fabiotchezaum 6 ปีที่แล้ว +2

    So let me see if I understood:
    If you pass only the parameter it goes like mandatory;
    if you pass an object as parameter it goes as optional;
    Is it correct?

    • @idlevandal69
      @idlevandal69 5 ปีที่แล้ว

      Hi Fabio, you probably have your answer by now but just in case someone else sees your question, the second parameter is of type NavigationExtras. If you go to the Angular docs and search for NavigationExtras you will see that there many different options you can pass as the second parameter to router.navigate().

  • @AnandAKGupta
    @AnandAKGupta 5 ปีที่แล้ว +1

    Hi, what is the preferred method to remove such Optional Route Parameters from the URL (individually)... for instance say if I use Relative Navigation from the next component (then these params still stay in the URL)
    I can manipulate the URL string and use router.navigateByUrl() instead of relative but that seems like dirty code. Any idea?

  • @chhotiBacchiNamHai
    @chhotiBacchiNamHai 4 ปีที่แล้ว +3

    I did this but the color did not change. Don't understand what is wrong with the code.

  • @ashwingowda2604
    @ashwingowda2604 4 ปีที่แล้ว +2

    If I click on next when I'm inside /departments/5, it will open departments/6 detail page. How to avoid that?

    • @garapatigokulsairam5889
      @garapatigokulsairam5889 2 ปีที่แล้ว +1

      add if condition and navigate to 404 error view or to home view. let id = this.deptId + 1;
      if(id >5)
      this.router.navigate(['']);
      else
      this.router.navigate([/'departments',id]);

  • @hatemalhasani
    @hatemalhasani 5 ปีที่แล้ว +2

    Angular has two ways to pass parameters in url
    1. router param almost part of route. e.g "/segment/1" // 1 is the id parameter.
    2. queryParams optional parameter. e.g "/segment?id=1.
    in this video [2.55] there is none compiled error line 43 it should be
    this.router.navigate(['/departments'], { queryParams: { id: 1 } });

  • @msh1996
    @msh1996 5 ปีที่แล้ว

    Great Videos

  • @Vikashkumar-vt9hl
    @Vikashkumar-vt9hl 4 ปีที่แล้ว

    Binding method to a property is not good practice. Instead you can bind a boolean property and updated it under the routeMap subscription.

    • @Krazness
      @Krazness 4 ปีที่แล้ว +1

      Can you explain why this is the better practice?

  • @DOHandDOH
    @DOHandDOH 4 ปีที่แล้ว

    Shouldn't the query parameters be separated using a question mark? The semicolon is part of 1994 spec, which is now obsolete and the semicolon notation is technically illegal.

    • @warek-bs5hs
      @warek-bs5hs 3 ปีที่แล้ว

      These are optional parameters, not query. Though in such case using query is better and more clear

    • @Jovialguy110
      @Jovialguy110 2 ปีที่แล้ว

      My doubt is why not use event emitting from child to parent class?

  • @OtakuBuzz-N
    @OtakuBuzz-N 4 ปีที่แล้ว

    Hi I it's returning to page not found
    What should I do

  • @xinaxtle9825
    @xinaxtle9825 4 ปีที่แล้ว

    gracias por los parametros opcionales

  • @sahilumredkar
    @sahilumredkar 4 ปีที่แล้ว

    When I click on back button id is showing in url it is right but it showing page not found what is solutions for that

    • @OtakuBuzz-N
      @OtakuBuzz-N 4 ปีที่แล้ว

      At first u see what u have written the route for the department listComponent and then on the gotoDepartments in native write if u have written same to same as shown in video u have to write department if not check once

  • @priyanth123mohan
    @priyanth123mohan 6 ปีที่แล้ว

    hi vishwas I didn't get this point this.departmentId ? this.departmentId : null (1:50) can u pls expalin

    • @Codevolution
      @Codevolution  6 ปีที่แล้ว +7

      Hi Priyanth, It is a ternary operator. If departmentId has a value, that is assigned to selectedId. If there is no value, null is assigned to selectedId.
      For more info - developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator

    • @JuanCamiloCampoT95
      @JuanCamiloCampoT95 6 ปีที่แล้ว

      thank you, I had the same question. nice videos

    • @nasrihaithem9529
      @nasrihaithem9529 4 ปีที่แล้ว

      @@Codevolution if its not null then return departmentId ,else return null ?

    • @nasrihaithem9529
      @nasrihaithem9529 4 ปีที่แล้ว

      sorry i diidnt understand the semantic of it , if i assign departmentId to selectedId, the selectedId gonna be null if departmentId is ,else its gonna have the departmentId value !! i dont need a ternary operator here! it gonna be automatic no ?

  • @seenuvasanv
    @seenuvasanv 6 ปีที่แล้ว +1

    Thanks.

  • @dhome111
    @dhome111 4 ปีที่แล้ว

    (click) it's doesn't work with me i'm using angular 9 can any one help me