Johann-S / bs-stepper

A stepper for Bootstrap 4.x
https://johann-s.github.io/bs-stepper/
MIT License
443 stars 88 forks source link

Please give example of Form validation in angular #315

Open rajnesh-rathor-auxano opened 1 year ago

rajnesh-rathor-auxano commented 1 year ago

I have tried HTML one but not able to successfully implement it in angular. could someone please

HenryKim2022 commented 1 year ago

Me too :) never working as sampled on AdminLTE3

rajnesh-rathor-auxano commented 1 year ago

I have implemented it in angular

@ViewChild('stepper1', { static: false }) stepperRef!: ElementRef;

        this.stepper = new Stepper(this.stepperRef.nativeElement, {
            linear: false,
            animation: true,
        });

        const validateForm1Fields = [
            'firstName',
            'lastName',
            'gender',
            'email',
            'mobileNumber',
            'governmentId',
            'address',
            'zipCode',
            'country',
            'state',
            'city',
        ];

        this.renderer2.listen(this.stepperRef.nativeElement, 'show.bs-stepper', (event: any) => {
            if (event.detail.from === 0) {
                if (
                    !validateForm1Fields.every((x) => this.ngForm.controls[x].status === 'VALID')
                ) {
                    this.submitted = true;
                    event.preventDefault();
                } else {
                    this.completedStep1 = true;
                    this.submitted = false;
                }
            }
        });
    }
`