Johann-S/bs-stepper

Cannot read properties of null (reading 'classList') at bs-stepper.js:265:17

adrian-badulescu opened this issue · 1 comments

I am trying to implement this library to an angular project as per this StackBlitz example https://stackblitz.com/edit/bs-stepper-angular?file=src%2Fapp%2Fapp.component.ts but I am getting this error.

I mention that I am using the npm package

My implementation:
controller.ts
``
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormBuilder, FormControl, FormArray, FormGroup } from '@angular/forms';
import { IContactForm } from '../interfaces/contactForm';
import { Validators } from '@angular/forms';
import { debounceTime, distinctUntilChanged, filter, fromEvent, map, switchMap, tap, catchError, of, retry, Observable, Subscription, iif, finalize, Subject, BehaviorSubject } from 'rxjs';

import { BackendService } from 'app/services/backend/backend.service';
import { SpinnerService } from 'app/services/spinner/spinner.service';
import { ActivatedRoute } from '@angular/router';
import Stepper from 'bs-stepper';

@component({
selector: 'app-order-form',
templateUrl: './order-form.component.html',
styleUrls: ['./order-form.component.css']
})

export class OrderFormComponent implements OnInit, OnDestroy {

contactForm: FormGroup;
domainSearchResult?: boolean;
showContactFrom: boolean = false;
submitted = false;
searchingSpinner?: boolean = false;
keyClicksSubscription: Subscription = new Subscription();
routeParamsSubscription: Subscription = new Subscription();
displaySpinner: BehaviorSubject = this._spinnerService.spinnerBooleanState;
templateTitle: string = '';
templateId: string = '';
private stepper!: Stepper;

constructor(private _fb: FormBuilder,
private _backendService: BackendService,
private _spinnerService: SpinnerService,
private route: ActivatedRoute) {
this.contactForm = this._fb.group({
webdomain: [null,[Validators.pattern]],
contactForm: this._fb.group({
surname: [null, [Validators.required]],
firstname: [null, [Validators.required]],
email: [null, [Validators.required]],
phone: [null]
})
});
}

get surname() {return this.contactForm.controls.contactForm.get('surname')};
get firstname() {return this.contactForm.controls.contactForm.get('firstname')};
get email() {return this.contactForm.controls.contactForm.get('email')};
get phone() {return this.contactForm.controls.contactForm.get('phone')};

onSubmit() {
this.submitted = true;
// TODO: Use EventEmitter with form value
console.log(this.contactForm.value);
}

keyClicks(): Observable {
const searchBox = document.getElementById('webdomain') as HTMLInputElement;
const keyboardInput = fromEvent(searchBox, 'input').pipe(
map(e => (e.target as HTMLInputElement).value),
filter(text => text.length > 4),
debounceTime(2000),
distinctUntilChanged(),
switchMap(searchTerm => this._backendService.searchDomain(searchTerm))
)
.pipe(
// tap(httpQueryResultAsBoolean => this.addContactFields(httpQueryResultAsBoolean))
)
return keyboardInput;
}

nextStep() {
this.stepper.next();
}

ngOnInit(): void {
this.keyClicksSubscription = this.keyClicks().subscribe(KeyboardEvent => this.domainSearchResult = KeyboardEvent);
this.routeParamsSubscription = this.route.queryParams
.subscribe(params => {
this.templateTitle = params.order;
this.templateId = params.Id;
console.log(Template Title: ${this.templateTitle} - Template Id: ${this.templateId}); // popular
});
this.stepper = new Stepper(document.querySelector('#stepper1'), {
linear: false,
animation: true
})
}

ngOnDestroy(): void {
this.keyClicksSubscription.unsubscribe();
this.routeParamsSubscription.unsubscribe();
}

}
``

component.html
``

1 Cauta domeniu liber
2 Date de contact
3 Personalizeaza
Cauta domeniul
Next
Nume*
Câmpul Nume este necesar
Prenume
Câmpul Prenume este necesar
E-mail*
Câmpul E-mail este necesar
Telefon
Password is required
Submit
    </div>
    <div class="col-lg-2 col-sm-4 col-xs-4">

    </div>
    <div class="col-lg-4 col-sm-4 col-xs-4"></div>
</div>    
`` package.json `` { "name": "newtd", "version": "0.0.0", "scripts": { "ng": "ng", "prestart": "node aspnetcore-https", "start": "run-script-os", "start:windows": "ng serve --port 44417 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem --ssl-key %APPDATA%\\ASP.NET\\https\\%npm_package_name%.key", "start:default": "ng serve --port 44417 --ssl --ssl-cert $HOME/.aspnet/https/${npm_package_name}.pem --ssl-key $HOME/.aspnet/https/${npm_package_name}.key", "build": "ng build", "build:ssr": "ng run newTD:server:dev", "watch": "ng build --watch --configuration development", "test": "ng test" }, "private": true, "dependencies": { "@angular/common": "^14.0.3", "@angular/compiler": "^14.0.3", "@angular/core": "^14.0.3", "@angular/forms": "^14.0.3", "@angular/localize": "^14.0.3", "@angular/platform-browser": "^14.0.3", "@angular/platform-browser-dynamic": "^14.0.3", "@angular/platform-server": "^14.0.3", "@angular/router": "^14.0.3", "@ng-bootstrap/ng-bootstrap": "^13.0.0", "@nguniversal/module-map-ngfactory-loader": "^8.2.6", "@popperjs/core": "^2.11.7", "bootstrap": "^5.2.3", "bs-stepper": "^1.7.0", "ng-recaptcha": "^10.0.0", "oidc-client": "^1.11.5", "popper.js": "^1.16.0", "run-script-os": "^1.1.6", "rxjs": "~7.5.5", "tslib": "^2.4.0", "zone.js": "~0.11.6" }, "devDependencies": { "@angular-devkit/build-angular": "^14.0.3", "@angular/cli": "^14.0.3", "@angular/compiler-cli": "^14.0.3", "@types/jasmine": "~4.0.3", "@types/jasminewd2": "~2.0.10", "@types/node": "^18.0.0", "jasmine-core": "~4.2.0", "karma": "~6.4.0", "karma-chrome-launcher": "~3.1.1", "karma-coverage": "~2.2.0", "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "^2.0.0", "typescript": "~4.7.4" }, "overrides": { "autoprefixer": "10.4.5" } }

``

Please let me know if you need any other iformation from my side.

Thank you!