Subscribe to angular route parameter changes

Поделиться
HTML-код
  • Опубликовано: 31 дек 2024

Комментарии • 17

  • @Elboukhario
    @Elboukhario 6 лет назад +1

    thanks! I appreciate your hard work!

  • @hellokishorshrestha
    @hellokishorshrestha 3 года назад +1

    how to give dynamic value in if condition eg. (this._id < arrayname.length) instead of (this._id < 3)

  • @ajeeteppakayala6788
    @ajeeteppakayala6788 5 лет назад

    Thanks Sir! for making this video.
    This cleared me everything.

  • @karanaggarwal7016
    @karanaggarwal7016 6 лет назад

    What if while using snapshot method we navigate back to the same component and do not write that code (which is written inside ng_on_init method) inside ng_on_init method..? Will it work fine?

  • @sourishdutta9600
    @sourishdutta9600 6 лет назад

    Nice one but in real world app IDs are not going to created like this approach, then how to tackle this id in employee details component.I will be so grateful if you give me the answer regarding this.Thanks.

  • @lenavogt2622
    @lenavogt2622 4 года назад

    hello, u helped me today....really with update route.navigation. Where can i find ur full list of angular videos??

  • @ashutoshkushawaha6664
    @ashutoshkushawaha6664 6 лет назад

    can i use third party jquery library in our angular 5 project. Please give me a solution. example jquery datatable plugin in angular 5 project.

  • @mutokvachi4713
    @mutokvachi4713 4 года назад

    Best one, LIKE

  • @ashutoshkushawaha6664
    @ashutoshkushawaha6664 6 лет назад

    can i use third party jquery library in our angular 5 project. Please give me a solution.

  • @mahmoudtaha1871
    @mahmoudtaha1871 3 года назад

    very thanks

  • @nitinpatil4306
    @nitinpatil4306 4 года назад

    i still did not get why this_router.navigate is not changing employee to next employee. this is what job of _router.navigate method is to refresh or route the page.

  • @debayansaha820
    @debayansaha820 6 лет назад

    Please give me steps so that we don't have to hardcode the values when the list enters the last item

  • @gunnarweisskamp1530
    @gunnarweisskamp1530 6 лет назад

    very good

  • @murthypalakeerthi7454
    @murthypalakeerthi7454 5 лет назад

    super

  • @luisbrazilva
    @luisbrazilva 3 года назад

    So far, a great tutorial but this particular lesson is flawed.
    First, this assumes that the IDs will be in exact order (1, 2, 3, 4, 5...nth). It's a bad idea to assume this. If an employee is deleted (i.e. ID=4), then the code breaks because it is told to go up incrementally.
    Second, the ceiling of the conditions to check for before it loops back to the beginning should be done by calling the service data array length. Instead of hard-coding it to 3 or any number. Again, what happens if someone gets deleted or added?
    employees: Employee[];
    ngOnInit() {
    this.employees = this._employeeService.getEmployees();
    this._route.paramMap.subscribe(params => {
    this._id = +params.get('id')
    this.employee = this._employeeService.getEmployee(this._id);
    });
    }
    viewNextEmployee() {
    if( this._id < this.employees.length ){
    this._id = this._id + 1; //this should use the this.employees index
    this._router.navigate(['/employees', this._id])
    } else {
    this._id = 111111; //this should return you to the employees index = 1
    }
    }
    Third, even if you used the IDs to find if this._id < the.employees.length. That will fail if the ID numbers do not start from 1. In other words, if the employee's IDs are ID=11111, ID=22222, and ID=677483. Then the logic fails because all of those IDs are > 3 which is the.employees.length.
    I recommend using index for this logic
    But great job nonetheless. If you could re-do this portion with those fixes, you will have a complete lesson.

  • @bkarthikkannan
    @bkarthikkannan 6 лет назад

    Below code works fine without subscribe.
    this.employee= this._employeeservice.getEmployee(this._id);
    this._router.navigate(['/employees',this._id]);