Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
angular2 wizard navigation history

https://github.com/maiyaporn/angular2-wizard

https://maiyaporn.github.io/angular2-wizard-demo/ (DEMO)

So I'm using this simple wizard for my application and I'm trying to figure out how I can navigate back and forth (either using the browser's back and forward buttons or click on the mouse to go back or forwards).

If you go through the demo provided, when you reach step 2 but want to go back, it seems like the only way to actually go back to step 1 is to click the "previous" button.

I want to be able to actually click "back" (in my case, with my mouse) so I can go back to step 1; clicking "back" with my mouse ends up taking me back to a previous page instead.

I've tried messing with history.pushState() but it still does not go back to step 1 like I want.

This is a little confusing and new to me as I am getting my feet wet with angular2. Since this is a parent-with-many-child-components on one page, it doesn't look like I can use hashes (I could be wrong).

Just would like to get some help on what I could take a look at to point me in the right direction.

Thanks in advance.

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Believe I figured out the answer to my question.

It may just be a hack and probably not a proper answer but it's working like I want it for now.

I basically went into the wizard-component.ts file and gave each step a hash. I then used onpopstate to listen for the history and used the goToStep method to find the correct step (by the hash).

over 4 years ago · Santiago Trujillo Relatório

0

You are going to want to use Routing.

Follow the tutorial: https://angular.io/docs/ts/latest/tutorial/toh-pt5.html

In brief

  1. Add <base href="/"> to index.html
  2. Import RouterModule in root module: import { RouterModule } from '@angular/router';
  3. Add Routes to root module: RouterModule.forRoot([{ path: 'heroes', component: HeroesComponent }])
  4. Insert router outlet into html template: <router-outlet></router-outlet>
  5. Start using routerLinks: <a routerLink="/heroes">Heroes</a>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda