benmarch / angular-bootstrap-tour

AngularJS wrapper around Bootstrap Tour
64 stars 27 forks source link

How to autostart the tour ? #6

Closed capic closed 9 years ago

capic commented 9 years ago

Hi, is it possible to autostart (depends to a condition) a tour without clicking on a button ? Thanks

benmarch commented 9 years ago

Hey sorry for the delay... this can be done in a controller by interacting with the tour object on the scope when the controller loads. Would it be helpful to have an attribute that will evaluate to a boolean and start if true? I think that would be the only alternative.

ll2585 commented 9 years ago

Can you give an example of this? Thanks!

benmarch commented 9 years ago

Something like this should work:

<div tour>
    <div ng-controller="AutoStartController">
    </div>
</div>
app.controller('AutoStartController", function ($scope) {
    var tourStarted = $scope.$watch('tour', function (tour) {
        if (tour) {
            tour.start(true);
            tourStarted();
        }
    });
});
aendra-rininsland commented 9 years ago

Confirming the above suggestion works.