angular-archwizard-demo
angular-archwizard-demo copied to clipboard
[CanExit] and [CanEnter] does not pass the MovingDirection
Hi,
I'm trying to use the [CanExit] property to perform form validation before moving to the next step; and to ignore validation for stepping backwards. However, the designated function to be called does not have access to the methods that are in the same Typescript file. It's like they're on 2 separate scopes. If I use an instantiated method (i.e. [canExit]="myFunction()"), the method would have access to the neighboring methods but the MovingDirections argument is not passed. Should I use a different property for this? I don't want the wizard to move forward if the form is invalid.
public onCanExitQuestionsStep(movingDirection): boolean {
if (movingDirection == MovingDirection.Forwards) {
if (this.quoteFormValues && this.quoteFormValues.qualityQuestions.every(x => x.valid)) {
console.log('All questions are valid');
return true;
}
console.log('All questions are not valid');
return false;
} else {
// Assume we are moving backwards
console.log('moving backwards');
return true;
}
}
`
It appears this library is looking for a specific method signature for it to work. This worked for me. public onCanExitQuestionsStep: (MovingDirection) => boolean = (movingDirection) =>{ }
public onCanExitQuestionsStep: (MovingDirection) => boolean = (movingDirection) =>{
if (movingDirection == MovingDirection.Forwards) {
if (this.quoteFormValues && this.quoteFormValues.qualityQuestions.every(x => x.valid)) {
console.log('All questions are valid');
return true;
}
console.log('All questions are not valid');
return false;
} else {
// Assume we are moving backwards
console.log('moving backwards');
return true;
}
}