Getting Started with Angular File Manager component

21 Jul 20267 minutes to read

The File Manager component provides a graphical user interface for browsing, managing, and organizing files and folders. This section explains how to create a simple File Manager component and its basic usage.

Prerequisites

Requirement Version
Angular 12 and above
Node.js 14.0.0 or above, Recommended: Latest Version

Angular supported versions

Angular Version Minimum Syncfusion® Angular File Manager Version
Angular v20 29.2.8
Angular v19 26.1.35
Angular v18 25.2.3
Angular v17 23.2.4
Angular v16 21.1.39
Angular v15 20.4.38
Angular v14 20.2.36
Angular v13 19.4.38 and above
Angular v12 19.3.43

Browser Support

Browser Supported Versions
Google Chrome, including Android & iOS Latest 2 versions
Mozilla Firefox Latest version
Microsoft Edge Latest 2 versions
Apple Safari, including iOS Latest 2 versions

Setup the Angular application

A straightforward approach to beginning with Angular is to create a new application using the Angular CLI. Install Angular CLI globally with the following command:

npm install -g @angular/cli

Angular 21 Standalone Architecture: Standalone components are the default in Angular 21. This guide uses the modern standalone architecture. If you need more information about the standalone architecture, refer to the Standalone Guide.

Create a new application

With Angular CLI installed, execute this command to generate a new application:

ng new syncfusion-angular-app
  • This command will prompt you to configure settings like enabling Angular routing and choosing a stylesheet format.
? Which stylesheet format would you like to use? (Use arrow keys)
> CSS             [ https://developer.mozilla.org/docs/Web/CSS                     ]
  Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
  Sass (Indented) [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]
  Less            [ http://lesscss.org                                             ]
  • By default, a CSS-based application is created. Use SCSS if required:
ng new syncfusion-angular-app --style=scss
  • During project setup, when prompted for the Server-side rendering (SSR) option, choose the appropriate configuration.

Initial_setup

  • Select the required AI tool or ‘none’ if you do not need any AI tool.

Initial_setup

  • Navigate to your newly created application directory:
cd syncfusion-angular-app

Note: In Angular 19 and below, it uses app.component.ts, app.component.html, app.component.css etc. In Angular 20+, the CLI generates a simpler structure with src/app/app.ts, app.html, and app.css (no .component. suffixes).

Adding Syncfusion® Angular packages

To install the File Manager component, use the following command:

npm install @syncfusion/ej2-angular-filemanager --save

Adding CSS reference

Themes for Syncfusion® File Manager components can be applied using CSS files provided through npm theme packages. For available themes, refer to the Themes documentation.

Install the Material 3 theme package using the following command:

npm install @syncfusion/ej2-material3-theme --save

Then add the following CSS reference to the src/style.css file:

@import "../node_modules/@syncfusion/ej2-material3-theme/styles/file-manager/index.css";

For using SCSS styles, refer to this guide.

Add File Manager component

Modify the template in the src/app/app.ts file to render the File Manager component. Add the Angular File Manager by using <ejs-filemanager> selector in template section of the app.ts file.

The ajaxSettings property must be defined while initializing the File Manager. File Manager utilizes the URLs mentioned in ajaxSettings to send file operation requests to the server. The File Manager service link is provided in the hostUrl variable.

Server-side setup

The sample uses https://physical-service.syncfusion.com/ as the url endpoint in ajaxSettings.

To use your own files, host a File Manager service and replace the url value with your service endpoint. See the File System Provider documentation for setup details.

import { BrowserModule } from '@angular/platform-browser'
import { NgModule } from '@angular/core'
import { FileManagerModule } from '@syncfusion/ej2-angular-filemanager'
import { Component } from '@angular/core';

@Component({
  imports: [FileManagerModule,],
  standalone: true,
  selector: 'app-root',
  template: `<ejs-filemanager id='default-filemanager' #filemanagerObj [ajaxSettings]='ajaxSettings' height="375px">
  </ejs-filemanager>`
})
export class App {
  public hostUrl: string = 'https://physical-service.syncfusion.com/';
  public ajaxSettings: object = {
    url: this.hostUrl + 'api/FileManager/FileOperations'
  };
}
@import "node_modules/@syncfusion/ej2-material3-theme/styles/file-manager/index.css";
import { bootstrapApplication } from '@angular/platform-browser';
import { App } from './app.component';
import 'zone.js';
bootstrapApplication(App).catch((err) => console.error(err));

Registering Your Syncfusion License

Before using Syncfusion components, generate a license key from the Syncfusion License Dashboard and register

Open the main.ts file and add the following code:

import { registerLicense } from '@syncfusion/ej2-base';
registerLicense('YOUR_LICENSE_KEY');

Note: A valid Syncfusion license is required for production use. If a valid license is not registered, a trial license warning message will be displayed when the application runs.

Run the application

Use the npm start command to run the application in the browser:

npm start

Production Build

To create an optimized production build, run:

ng build

This command compiles the application and generates the production-ready files in the dist/ directory.

To preview the production build locally, run:

npx http-server dist

Then open the URL displayed in the terminal.

Troubleshooting

  • File Manager styles are not applied: Ensure the required Syncfusion theme CSS is imported in src/styles.css.
  • Trial license warning message: Register a valid Syncfusion license key using the registerLicense() method from @syncfusion/ej2-base.
  • Port 4200 is already in use: Stop the conflicting process or run the application on a different port:

    ng serve --port 3000

See also