Code Monkey home page Code Monkey logo

ngx-bootstrap-product-tour's Introduction

ngx-bootstrap-product-tour

npm version

About

This is a product tour library built with Angular (2+). NgxBootstrapProductTourModule is an implementation of the tour ui that uses ngx-bootstrap popovers to display tour steps.

For Angular 4 use package version 1.0.6

For Angular 5 use package version 2.0.x

Installation

  1. npm i ngx-bootstrap-product-tour ngx-bootstrap bootstrap
  2. Import NgxBootstrapProductTourModule.forRoot() into your app module
  3. Make sure RouterModule is imported in your app module
  4. Include bootstrap css.

Usage

  1. Add <ngx-bootstrap-product-tour></ngx-bootstrap-product-tour> to your root app component

  2. Define anchor points for the tour steps by adding the tourAnchor directive throughout your app.

    <div tourAnchor="some.anchor.id">...</div>
  3. Define your tour steps using tourService.initialize(steps)

    this.tourService.initialize([{
      anchorId: 'some.anchor.id',
      content: 'Some content',
      title: 'First',
    }, {
      anchorId: 'another.anchor.id',
      content: 'Other content',
      title: 'Second',
    }]);
  4. Start the tour with tourService.start()

Demo

Demo page can be found here and it's source code here.

TourService

The TourService controls the tour. Some key functions include

Function Description
start() Starts the tour
startAt(stepId: number | string) Start the tour at the step with stepId or at the specified index
end() Ends the tour
pause() Pauses the tour
resume() Resumes the tour
next() Goes to the next step
prev() Goes to the previous step

Step Configuration

Each step can have the following properties.

Name Type Default Description
stepId string "" A unique identifier for the step
anchorId string required The anchor to which the step will be attached
title string "" The title of the tour step
content string "" The content text of the tour step
route string UrlSegment[] undefined
nextStep number string undefined
prevStep number string undefined
placement 'top' | 'bottom' | 'right' | 'left' 'top' Where the tour step should placed with respect to the anchor.
preventScrolling boolean false Tour steps automatically scroll to the middle of the screen, if they are off the screen when shown. Setting this value to true will disable the scroll behavior.
containerClass string "" Css class for popover container.
orphan boolean false Tour popover will be placed in the center of the screen, must have anchorId but it won't be shown next to that element.
promise promise<any> "" Step shows after promise has been resolved.
delay number 0 Time in milliseconds before showing the tour step.
backdrop boolean false Shows/hides backdrop. You need to set backgroud color and z-index on class .tour-backdrop and higher z-index on .tour-step-backdrop.

Defaults

You can set default values in the TourService.initialize function.

this.tourService.initialize(steps, {{ '{' }}
  route: '',
  placement: 'left',
  preventScrolling: true,
});

Any value explicitly defined in a step will override the default value.

Event Observables

The TourService emits events that can be subscribed to like this:

this.tourService.initialize$.subscribe((steps: IStep[]) => {{ '{' }}
  console.log('tour configured with these steps:', steps);
});
Name Payload Emitted When
stepShow$ IStep A step is shown
stepHide$ IStep A step is hidden
initialize$ IStep[] The tour is configured with a set of steps
start$ IStep The tour begins
end$ any The tour ends
pause$ IStep The tour is paused
resume$ IStepI The tour resumes
anchorRegister$ string An anchor is registered with the tour
anchorUnregister$ string An anchor is unregistered from the tour

Custom template

You can also customize the tour step template by providing an <ng-template> inside the <ngx-bootstrap-product-tour>

The default template is equivalent to this:

<ngx-bootstrap-product-tour>
  <ng-template #tourStep>
    <p class="tour-step-content">{{tourService.currentStep.content}}</p>
    <div class="tour-step-navigation">
      <button *ngIf="tourService.hasPrev(tourService.currentStep)" class="btn btn-sm btn-default" (click)="tourService.prev()">« Prev</button>
      <button *ngIf="tourService.hasNext(tourService.currentStep)" class="btn btn-sm btn-default" (click)="tourService.next()">Next »</button>
      <button class="btn btn-sm btn-error" (click)="tourService.end()">End</button>
    </div>
  </ng-template>
</ngx-bootstrap-product-tour>

ngx-bootstrap-product-tour's People

Contributors

angular-cli avatar dieguisherrera avatar nmilicic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ngx-bootstrap-product-tour's Issues

Support for Angular 5

Looks like this component is not compatible with Angular 5. Can you please help upgrade it to Angular 5 as well. It uses which is not supported in Angular 5.

Gettig below AOT error while adding the module in App module.

WARNING in ./node_modules/ngx-bootstrap-product-tour/node_modules/@angular/core/@angular/core.es5.js
5660:15-36 Critical dependency: the request of a dependency is an expression

Problem with AOT compilation in angular4

The problem occurs when you call tourService.start() or tourService.start At().
As the directive is a dinamycaly created component, in AOT the following problem shows:

ERROR Error: No component factory found for t. Did you add it to @NgModule.entryComponents?

The solution is simple https://hassantariqblog.wordpress.com/2017/02/12/angular2-error-no-component-factory-found-did-you-add-it-to-ngmodule-entrycomponents/

Is necessary to add in the ngx-bootstrap-product-tour.module.ts file the following code next to declarations in @NgModule declaration

entryComponents: [
NgxBootstrapProductTourDirective,
NgxBootstrapProductTourStepComponent
],

Cannot redeclare block-scoped variable 'ngDevMode'.

After every npm install I'm getting an error:

node_modules/ngx-bootstrap-product-tour/node_modules/@angular/core/src/render3/ng_dev_mode.d.ts(9,11): error TS2451: Cannot redeclare block-scoped variable 'ngDevMode'.

If to delete @angular folder from node_modules/ngx-bootstrap-product-tour/node_modules, it's compiling. But still I need to delete it every time I'm installing smth. Is it possible to fix this error once and forever?

P.S. I'm using angular 5

Pass boolean flag from one component to another component

How we can pass a boolean flag from one component to another component in touranchor id.

I have 3 components,for one component half part is first if and second is different component.

Third id is again the same first componet, another first part it has to show, which is flag protected.

So I want to pass the flag value.

How we can solve this?

containerScrollTop is not defined

Hi,

I'm getting this error when clicked on next in steps,

ERROR ReferenceError: containerScrollTop is not defined
at withinviewport (VM17853 vendor.bundle.js:15051)
at NgxBootstrapProductTourDirective.webpackJsonp.../../../../ngx-bootstrap-product-tour/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js.NgxBootstrapProductTourDirective.showTourStep (VM17853 vendor.bundle.js:15179)
at NgxBootstrapProductTourService.webpackJsonp.../../../../ngx-bootstrap-product-tour/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js.NgxBootstrapProductTourService.showStep (VM17853 vendor.bundle.js:14880)
at NgxBootstrapProductTourService.webpackJsonp.../../../../ngx-bootstrap-product-tour/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js.NgxBootstrapProductTourService.setCurrentStep (VM17853 vendor.bundle.js:14862)
at VM17853 vendor.bundle.js:14830
at wrapped (VM17853 vendor.bundle.js:39001)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (VM17849 polyfills.bundle.js:2942)
at Object.onInvokeTask (VM17853 vendor.bundle.js:100742)
at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (VM17849 polyfills.bundle.js:2941)
at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (VM17849 polyfills.bundle.js:2709)
at webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask (VM17849 polyfills.bundle.js:3016)
at ZoneTask.invoke (VM17849 polyfills.bundle.js:3005)
at timer (VM17849 polyfills.bundle.js:4557)

Angular 7 Support

Am getting this warning when trying to compile:

WARNING in ./node_modules/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js 15814:23-34
"export 'mergeStatic' was not found in 'rxjs/operator/merge'

Also then when it does actually compile (after addressing this issue: #14)

I get this error :

AppComponent_Host.ngfactory.js? [sm]:1 ERROR TypeError: Object(...) is not a function
at new NgxBootstrapProductTourService (ngx-bootstrap-product-tour.es5.js:15814)
at createClass (core.js:21263)
at createProviderInstance (core.js:21235)
at resolveNgModuleDep (core.js:21199)
at NgModuleRef
.push../node_modules/@angular/core/fesm5/core.js.NgModuleRef
.get (core.js:21907)
at resolveDep (core.js:22278)
at createClass (core.js:22152)
at createDirectiveInstance (core.js:22029)
at createViewNodes (core.js:23255)
at createRootView (core.js:23169)

It cannot construct the NgxBootstrapProductTourService when I inject it into the constructor.

Bundled version of component failing.

Im using Angular-cli to bundle my app. There is an error when the popoverDirective.show is being called.

main.bundle.js:1 ERROR Error: No component factory found for t. Did you add it to 
@NgModule.entryComponents?
    at we (main.bundle.js:1)
    at t.resolveComponentFactory (main.bundle.js:1)
    at t.attach (main.bundle.js:1)
    at e.t.show (main.bundle.js:1)
    at t.showTourStep (main.bundle.js:1)

I have routing module and ngx-bootstrap as a part of my project. Anything additional that needs ot be done?

Router error on angular5

Hello,

I can't seem to make the plugin work. I followed the tutorial & the sample app, yet I'm getting the following error for the line:
<ngx-bootstrap-product-tour></ngx-bootstrap-product-tour>

ERROR Error: StaticInjectorError(AppModule)[NgxBootstrapProductTourService -> Router]: 
  StaticInjectorError(Platform: core)[NgxBootstrapProductTourService -> Router]: 
    NullInjectorError: No provider for Router!

I'm using angular 5.2.9

Any help is much appreciated,

Thanks

unable to make it work on lazy load modules ngx-bootstrap-product-tour

hi I am using ngx-bootstrap-product-tour in my app. and i was imported this module in my app.module,

NgxBootstrapProductTourModule.forRoot(),

and initilized in app.component .ts

But this service is not working in the lazy loaded modules. and not getting any error. Later i tried to import module in lazy loaded module and re initialized in the lazy loaded component with no luck.

i tried to add NgxBootstrapProductTourModule.forChild(), but it throes an error , for child is not implemented in this module

can any one help me on how to implement this feature in lazy loaded modules.

tourService.end() called on Refresh.

How to prevent tourService.end() automatically gets called when I refresh the browser instrad of clicking any Prev,Next or End Buttton.

I want tourSrevice.end() to be called only when End button is pressed explicitly. Also I have used custom design for the buttons in app.component,html like this:

<ngx-bootstrap-product-tour>
  <ng-template #tourStep let-step="step">
    <p class="tour-step-content mb-1">{{tourService.currentStep.content}}</p>
    <div class="tour-step-navigation d-flex flex-row">
      <span *ngIf="tourService.hasPrev(tourService.currentStep)" class="badge badge-pill badge-secondary border border-secondary mr-2"
        (click)="tourService.prev()">Prev</span>
      <span *ngIf="tourService.hasNext(tourService.currentStep)" class="badge badge-pill badge-secondary border border-secondary"
        (click)="tourService.next()">Next</span>
      <span class="badge badge-pill badge-light border border-secondary ml-auto" (click)="tourService.end()">End</span>
    </div>
  </ng-template>

Can we add a image in popup?

Screenshot from 2019-06-24 15-01-00

Here can we add an image/ background image on a popup. I want to add or display on it. There is an option to do it or any other solutions?

Lazy loaded modules

Similar to this question on Stackoverflow, I am facing an issue wherein the tour works perfectly if there are no lazy loaded modules. However if I need the tour inside a lazy loaded module, the popover appears, but the popover-content div is empty.

I have followed the source code given the lazyLoading demo, and the popover does appear - but the backdrop does not show, and the popover-content div is empty.

Am using angular4, and ngx-bootstrap-product-tour v1.0.6. My tour is completely inside the lazy loaded module, including tour.start

@NMilicic could you provide any guidance on this issue?

Tour spanning multiple components

Hi @NMilicic , I was wondering if this is possible, as I did not see it in the docs.

I have a tour that spans a parent component and its child component. For e.g. Step 1 is anchored to a div in the parent component - on clicking "Next", Step 2 (anchored to a div in the child component) should be shown - can a tour like this be implemented using this package?

Thank you for your help!

ngx-bootstrap-product-tour is getting error as [email protected] is not supported with angular5

Hi, I am using ngx-bootstrap-product-tour with angular 5 it is working fine on the local machine.
when I run a Prod Build it throws the below error

ERROR in: "let-" is only supported on ng-template elements. ("
  </thead>
  <tbody>
    <template ngFor [ngForOf]="rows" [ERROR ->]let-rowz="$implicit" let-index="index">
      <tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].sec")
: "let-" is only supported on ng-template elements. ("
  </thead>
  <tbody>
    <template ngFor [ngForOf]="rows" let-rowz="$implicit" [ERROR ->]let-index="index">
      <tr *ngIf="!(datePicker.onlyCurrentMonth && rowz[0].secondary && rowz[6].sec")

I researched about this error, it says
ngx-bootstrap-product-tour is using [email protected] but it is throwing an error in angular5

as per below link

valor-software/ngx-bootstrap#3024

saying that need to update [email protected] to [email protected].
is there any solution to update the dependency to make it work in angular5.

No component factory found. Did you add it to @NgModule.entryComponents?

ERROR in Error during template compile of 'NgxBootstrapProductTourModule'.
Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'NgModule'.
'NgModule' calls 'ɵmakeDecorator'
Cannot redeclare block-scoped variable 'ngDevMode'.

Angular version: 5.x.x
ngx-bootstrap-product-tour: 2.0.2

PS. These issues only happen in Prod. Works perfectly on local.

Error with build --prod ERROR in ./node_modules/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js 4:9

I have problem when build with prod mode. Pls help
ERROR in ./node_modules/ngx-bootstrap-product-tour/ngx-bootstrap-product-tour.es5.js 4:9
Module parse failed: Identifier '__extends' has already been declared (4:9)
You may need an appropriate loader to handle this file type.
| import { __decorate } from "tslib";
| import { __metadata } from "tslib";

import { __extends } from "tslib";
| import { ApplicationRef, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentFactoryResolver, ContentChild, Directive, ElementRef, EventEmitter, Host, HostBinding, HostListener, Inject, Injectable, Injector, Input, NgModule, NgZone, Optional, Output, ReflectiveInjector, Renderer2, TemplateRef, ViewChild, ViewChildren, ViewContainerRef, ViewEncapsulation, forwardRef, isDevMode } from '@angular/core';
| import { CommonModule } from '@angular/common';

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.