Git Product home page Git Product logo

angular-livechat's Introduction

Livechat Widget for Angular

Library to integrate LiveChat Widget with your Angular App.

Demo

StackBlitz live example.

Installation

npm install --save @livechat/angular-widget

Usage

Import LivechatWidgetModule in Angular AppModule.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { LivechatWidgetModule } from '@livechat/angular-widget'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
	BrowserModule,
	LivechatWidgetModule,
  ],
  providers: [],
  bootstrap: [
	  AppComponent,
	]
})
export class AppModule { }
Use the LiveChat Angular Widget in your template:
<livechat-widget licenseId="10073628"></livechat-widget>

As optional parameters, you can define:

  • group
  • chatBetweenGroups
  • params
  • visitor
  • gaVersion

To get more details about usage of the optional paramteres please read our tracking code documentation.

Access to the LiveChat Widget API using callback method
<livechat-widget licenseId="10073628" (onChatLoaded)="onChatLoaded($event)"></livechat-widget>
import { Component } from '@angular/core';
import { LiveChatWidgetApiModel } from '@livechat/angular-widget';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  liveChatApi: LiveChatWidgetApiModel

  constructor() { }

  onChatLoaded(api: LiveChatWidgetApiModel) {
    this.liveChatApi = api;
  }
}
Access to the LiveChat Widget API using @ViewChild decorator
<livechat-widget #liveChatWidget licenseId="10073628" ></livechat-widget>
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
import { LiveChatWidgetModel } from '@livechat/angular-widget';
import { Subscription } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent implements OnInit, OnDestroy {
  @ViewChild('liveChatWidget') liveChatWidget: LiveChatWidgetModel;
  liveChatWidget$: Subscription = new Subscription();
  liveChatApi: LiveChatWidgetApiModel;

  constructor() { }

  ngOnInit(): void {
    this.liveChatWidget$ = this.liveChatWidget.onChatLoaded.subscribe((api: LiveChatWidgetApiModel) => this.liveChatApi = api)
  }

  ngOnDestroy(): void {
	  this.liveChatWidget$.unsubscribe();
  }
}

angular-livechat's People

Contributors

medynski avatar walaszczykm avatar skix123 avatar softchicken avatar andarist avatar dochecknow avatar mreszke avatar

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.