Events in Angular Floating action button component

14 Nov 20222 minutes to read

This section explains the available events in Floating Action Button component.

created

Event triggers after the creation of Floating Action Button.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<!-- To Render Floating Action Button. -->
                <button ejs-fab id='fab' iconCss= 'e-icons e-edit' content= 'Edit' (created)="onCreate()"></button>`
})

export class AppComponent {

    onCreate() {
        //Your required action here
  };
 }

onclick

Event triggers when the Floating Action Button is clicked.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<!-- To Render Floating Action Button. -->
                <button ejs-fab id='fab' iconCss= 'e-icons e-edit' content= 'Edit' (click)="onclick()"></button>`
})

export class AppComponent {

    onclick() {
        //Your required action here
  };
 }

Below example demonstrates the click event of the Floating Action Button.

import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<div id="targetElement" style="position:relative;min-height:350px;border:1px solid;">
               </div>
               <!-- To Render Floating Action Button. -->
                <button ejs-fab id='fab' iconCss= 'e-icons e-edit' content= 'Edit' (click) ="onclick()" target= '#targetElement'></button>`
})

export class AppComponent {

    onclick() {
        alert("Edit is clicked!");
  };
 }
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { FabModule } from '@syncfusion/ej2-angular-buttons'

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
        FabModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);