Change routes when child component activate

Discussão em 'Angular' iniciado por A G, Dezembro 13, 2024.

  1. A G

    A G Guest

    I want to do a login page with password reset page. In the page, only a tiny part of the page will change when i click on "reset password" so the view will be like this :

    Login page:

    <div class="container">
    <div *ngIf="route is login">
    <login-component></login-component>
    </div>
    <div *ngIf="route is password forget">
    <password-forget-component></password-forget-component>
    </div>
    </div>


    When i click on password forgot button, i want the url to change from "/login" to "/login/forgot-password" for example. But it's in the same component and i don't know how to do this...

    I think that in the component.ts i have to listen to ActivatedRoute, check if the route is /login/forgot-password, and if so make the state like this.state = 'password-forgot' (and if route is /login the state would be this.state = 'login'), but it's juste an intuition.

    If you have better way of doing that also it would be nice thank you

    bonus : if i can make the change of views in a transition animation !

    Continue reading...

Compartilhe esta Página