Angular2 router - Navigate to the current page with different parameters

前端 未结 4 1951
梦毁少年i
梦毁少年i 2020-12-30 23:56

I am trying to route to the current page with different param with no avail. I have a combo box that triggers:

this.router.navigate([\'page\', selectedId]);
         


        
4条回答
  •  礼貌的吻别
    2020-12-31 00:35

    Ok, after reading all your answers specially @mxii's (thank you for this), I understand that:

    1. when routing to the same page with different param, only the param changes. the DOM stand still, no component rebuild, no onInit cycle.
    2. The OnChanges hook triggers on every data-bind changes, which mean if I pass the param to child component I can't use OnInit on with this param, I must use OnChanges hook.

    Good Lesson, Thanks!

提交回复
热议问题