Getting started with Angular Image editor component

27 Sep 20235 minutes to read

This section explains how to create and demonstrate the basic usage of the Angular Image Editor module.

To get started quickly with angular Image Editor component using angular CLI, you can check the video below.

Dependencies

The list of dependencies required to use the Image Editor module in your application is given below:

|-- @syncfusion/ej2-angular-image-editor
    |-- @syncfusion/ej2-angular-base
    |-- @syncfusion/ej2-base
     -- @syncfusion/ej2-data
    |-- @syncfusion/ej2-buttons
     -- @syncfusion/ej2-lists
    |-- @syncfusion/ej2-image-editor
    |-- @syncfusion/ej2-dropdowns
    |-- @syncfusion/ej2-inputs
    |-- @syncfusion/ej2-navigations
    |-- @syncfusion/ej2-popups
    |-- @syncfusion/ej2-splitbuttons

Setup Angular environment

You can use Angular CLI to setup your Angular applications. To install Angular CLI use the following command.

npm install -g @angular/cli

Create an Angular application

Start a new Angular application using below Angular CLI command.

ng new my-app
cd my-app

Installing Syncfusion Image Editor package

To install Image Editor package, use the following command.

npm install @syncfusion/ej2-angular-image-editor --save

The above package installs Image Editor dependencies which
are required to render the component in the Angular environment.

Adding Image Editor module

Import Image Editor module into Angular application(app.module.ts) from the package @syncfusion/ej2-angular-image-editor.

import { NgModule }      from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

// Importing ImageEditorModule from ej2-angular-image-editor package.
import { ImageEditorModule } from '@syncfusion/ej2-angular-image-editor';
import { AppComponent }  from './app.component';

@NgModule({
  imports:      [ BrowserModule, ImageEditorModule ], // Declaration of ImageEditor module into NgModule.
  declarations: [ AppComponent ],
  bootstrap:    [ AppComponent ]
})
export class AppModule { }

Adding Syncfusion Image Editor component

Modify the template in app.component.ts file to render the Angular Image Editor component.

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

@Component({
  selector: 'app-root',
  template: `<!-- To render Image Editor. -->
              <div id="wrapperDiv" style="width:550px;height:350px;">
               <ejs-imageeditor></ejs-imageeditor>
              </div>`
})
export class AppComponent  { }

Adding CSS reference

Add Angular Image Editor component’s styles as given below in style.css.

@import "../node_modules/@syncfusion/ej2-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-lists/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
@import "../node_modules/@syncfusion/ej2-dropdowns/styles/material.css";
@import "../node_modules/@syncfusion/ej2-inputs/styles/material.css";
@import "../node_modules/@syncfusion/ej2-image-editor/styles/material.css";

Running the application

Run the application in the browser using the following command:

ng serve

The following example shows a basic Image Editor component.

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

@Component({
    selector: 'app-root',
    template: `<div class="e-section-control">
              <!-- To render Image Editor. -->
              <div id="wrapperDiv" style="width:550px;height:350px;">
                <ejs-imageeditor></ejs-imageeditor>
              </div>
              </div>`
})

export class AppComponent {

}
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ImageEditorModule } from '@syncfusion/ej2-angular-image-editor';
import { AppComponent } from './app.component';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

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

import 'zone.js';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);

You can also explore our Angular Image Editor example that shows how to render the Image Editor in Angular.