troch / angular-multi-step-form

An angular module for creating multi step forms / wizards
http://troch.github.io/angular-multi-step-form
ISC License
144 stars 44 forks source link

Next and previous titles not working as intended #34

Closed remib closed 8 years ago

remib commented 8 years ago

Sorry to reopen this but after much experimentation I'm still not achieving the desired outcome.

I am using the following code for next and previous buttons to show the title of the respective pages alongside the button:

<strong ng-bind-template="{{$isFirst() ? null : $getSteps()[$getActiveIndex() - 1].title}}"></strong>

<strong ng-bind-template="{{$isLast() ? null : $getSteps()[$getActiveIndex() + 1].title}}"></strong>

However this does not have the desired outcome. I have created an example array of steps whose titles are numbers from 1-6 to see what is going on.

When the page initially loads I see: Next: 3 (where this should be 2)

Then as I click next through the steps I see: Previous: 2, Next: 4 (should be 1,3) Previous: 3, Next: 5 (should be 2, 4) Previous: 4, Next:6 (should be 3, 5) Previous: 5, Next: blank/null (should be 4, 6) Previous: 6, Next: null (should be 5, null)

troch commented 8 years ago

Yep, sorry about that. Steps indexes starts at 1.

<strong ng-bind-template="{{$isFirst() ? null : $getSteps()[$getActiveIndex() - 2].title}}"></strong>

<strong ng-bind-template="{{$isLast() ? null : $getSteps()[$getActiveIndex()].title}}"></strong>
remib commented 8 years ago

Of course! It's late and my brain isn't working, time to stop! Thanks a lot.