Articles in this section
Category / Section

How to get started easily with Syncfusion Angular 9 Split Button ?

2 mins read

A quick start project that helps you to create an Angular 9 Split Button with a minimal code configurations.

Angular 9 Split Button

The following section explains you how to create a simple angular 9 Split Button component.

Prerequisites

Before start, we need following items to create Angular Split Button in Angular 9 application

Dependencies

The angular 9 Split Button is created from the Syncfusion ej2-angular-splitbuttons package from npmjs, which are distributed in npm as @syncfusion scoped packages.

Creating Angular Project

  • Install Angular cli 9 using following command.
    npm install -g @angular/cli@9.0.2
    

 

Note:

If you would like to follow and run the application in Angular 8 or Angular 7 or Angular 6, you need to replace the CLI command version number with the corresponding angular version number.

 

npm install -g @angular/cli@<CLI VERSION>

  • Create a new Angular 9 project using Angular cli and navigate to that folder.
    ng new <project name>
    cd <project name>
    

      

Adding Angular Split Button

  • After running the Angular 9 application successfully, configure the Angular Split Button in this application. Install Angular Split Button and EJ2 package using following command. The --save command will instruct the NPM to include a Split Button package inside the dependencies section of the package.json.
    npm install @syncfusion/ej2-angular-splitbuttons --save
    

          

  • Import SplitButtonModule from installed package.
  • Import and inject the other required modules within the providers section of app.module.ts.
    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { SplitButtonModule } from '@syncfusion/ej2-angular-splitbuttons';
    import { AppComponent } from './app.component';
     
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        SplitButtonModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule {} 
    
  • Add the given below angular Split Button’s styles in styles.css.
    @import "../node_modules/@syncfusion/ej2-base/styles/material.css";
    @import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
    @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
    @import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
    
  • Add the angular Split Button component in app.component.ts.
    import { Component } from '@angular/core';
    import { ItemModel } from '@syncfusion/ej2-angular-splitbuttons';
     
    @Component({
        selector: 'app-root',
        template: `<ejs-splitbutton content='Paste' [items]= 'items'></ejs-splitbutton>`
    })
    export class AppComponent {
     public items: ItemModel[] = [
        {text: 'Cut'},
        {text: 'Copy'},
        {text: 'Paste'}
        ];
    }
    
  • Now serve the application using following command.
    ng serve 
    

Once the files are compiled successfully, it will serve the site at localhost:4200

Screenshot:

          split button preview

Summary

Refer to our documentation and online samples for more features. If you have any queries, please let us know in comments below.  You can also contact us through our Support forum or Direct-Trac. We are happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied