mendhak / angular-intro.js

AngularJS directives for intro.js
http://code.mendhak.com/angular-intro.js/
GNU Affero General Public License v3.0
503 stars 175 forks source link

start(step) doesn't match docs #146

Open whatllb opened 7 years ago

whatllb commented 7 years ago

I'm trying to start an intro at step 0 with start(0), and encountering a problem:

TypeError: Cannot read property 'element' of undefined at IntroJs._showElement (intro.js:788) at IntroJs._nextStep (intro.js:357) at IntroJs._goToStep (intro.js:300) at IntroJs.goToStep (intro.js:1843) at Object.start (angular-intro.js:79) at

From my tracing, it looks like a low number will cause an exception, and a higher number may cause it to start one step off. I haven't tested the possibilities.

There may be a problem due to the sequence performed:

http://introjs.com/docs/intro/api/#introjsgotostepstep shows to perform the goToStep, then the start.

    introJs().goToStep(2).start(); //starts introduction from step 2

angular-intro.js performs start then goToStep:

    start(step?: number) {
        if (typeof (step) === "number") {
            this.intro.start().goToStep(step);
        } else {
            this.intro.start();
        }
        this.notifyListeners(introStatus.open);

        return this.intro;
    }

I see goToStepNumber(stepNumber) in the IntroJs docs, but it wants to be before start() as well. To get around this, I may grab the intro object and set the initial state myself. Ex:

                    let intro = ngIntroService.intro;
                    intro.goToStep(0);
                    ngIntroService.start();
whatllb commented 7 years ago

Ugh. goToStep() appears to take a 1-based step number, not an index. It appears to work fine with passing ngIntroService.start(1). You should consider the sequence mismatch before closing this issue.

Thanks