|
1 | | -# Integrating Syncfusion Angular Components with Angular and Electron Applications |
| 1 | +# ElectronApp |
2 | 2 |
|
3 | | -This document helps you to create a simple Angular application with `Electron Framework` and `Syncfusion Angular UI components`. |
| 3 | +This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.2.13. |
4 | 4 |
|
5 | | -## Prerequisites |
| 5 | +## Development server |
6 | 6 |
|
7 | | -Before getting started with the Angular project, make sure you have the following installed on your machine, |
| 7 | +To start a local development server, run: |
8 | 8 |
|
9 | | -* [System requirements for Syncfusion Angular UI components](https://ej2.syncfusion.com/angular/documentation/system-requirement) |
10 | | -* Electron CLI version - `^22.x.x` or later |
| 9 | +```bash |
| 10 | +ng serve |
| 11 | +``` |
11 | 12 |
|
12 | | -If you do not have the `Electron CLI` installed, refer to the [`Electron package`](https://www.npmjs.com/package/electron-cli) for instructions on how to install it. |
| 13 | +Once the server is running, open your browser and navigate to `http://localhost:4200/`. The application will automatically reload whenever you modify any of the source files. |
13 | 14 |
|
14 | | -## Getting started with Syncfusion Angular component |
| 15 | +## Code scaffolding |
15 | 16 |
|
16 | | -Follow the [documentation](https://ej2.syncfusion.com/angular/documentation/getting-started/angular-cli) to create an Angular application that includes Syncfusion Angular components. |
| 17 | +Angular CLI includes powerful code scaffolding tools. To generate a new component, run: |
17 | 18 |
|
18 | | -## Create main.js file |
| 19 | +```bash |
| 20 | +ng generate component component-name |
| 21 | +``` |
19 | 22 |
|
20 | | -Create a `main.js` file in the root folder of the project and update the below code, This file will serve as an entry-point for Electron and it is responsible for creating windows and handling all the system events that might occur in the app. |
| 23 | +For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run: |
21 | 24 |
|
22 | | -```typescript |
23 | | -const { app, BrowserWindow } = require('electron'); |
24 | | -let win; |
| 25 | +```bash |
| 26 | +ng generate --help |
| 27 | +``` |
25 | 28 |
|
26 | | -function createWindow() { |
27 | | - win = new BrowserWindow({ width: 800, height: 600 }); |
| 29 | +## Building |
28 | 30 |
|
29 | | - // Load the Angular app in the browser window |
30 | | - win.loadFile('./dist/sample15/index.html'); |
| 31 | +To build the project run: |
31 | 32 |
|
32 | | - win.on('closed', () => { |
33 | | - win = null; |
34 | | - }); |
35 | | -} |
| 33 | +```bash |
| 34 | +ng build |
| 35 | +``` |
36 | 36 |
|
37 | | -app.on('ready', createWindow); |
| 37 | +This will compile your project and store the build artifacts in the `dist/` directory. By default, the production build optimizes your application for performance and speed. |
38 | 38 |
|
39 | | -app.on('window-all-closed', () => { |
40 | | - if (process.platform !== 'darwin') { |
41 | | - app.quit(); |
42 | | - } |
43 | | -}); |
| 39 | +## Running unit tests |
44 | 40 |
|
45 | | -app.on('activate', () => { |
46 | | - if (win === null) { |
47 | | - createWindow(); |
48 | | - } |
49 | | -}); |
| 41 | +To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command: |
50 | 42 |
|
| 43 | +```bash |
| 44 | +ng test |
51 | 45 | ``` |
52 | 46 |
|
53 | | -## Update index.html |
54 | | - |
55 | | -In the `/src/index.html` file, change `<base href="/">` to `<base href="./">`, so that the Electron can able to find the Angular files. |
56 | | - |
57 | | -## Update package.json |
| 47 | +## Running end-to-end tests |
58 | 48 |
|
59 | | -Go to your root directory and find the package.json file. Open its content and add the following, |
| 49 | +For end-to-end (e2e) testing, run: |
60 | 50 |
|
61 | | -```typescript |
62 | | -"main":"main.js", |
63 | | -"scripts": { |
64 | | - "ng": "ng", |
65 | | - "start": "ng serve", |
66 | | - "build": "ng build", |
67 | | - "test": "ng test", |
68 | | - "lint": "ng lint", |
69 | | - "e2e": "ng e2e", |
70 | | - "electron-build": "ng build --configuration=production", |
71 | | - "electron": "electron ." |
72 | | -}, |
| 51 | +```bash |
| 52 | +ng e2e |
73 | 53 | ``` |
74 | 54 |
|
75 | | -## Running the application |
| 55 | +Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs. |
76 | 56 |
|
77 | | -Finally, run the following command line to start the application. The Syncfusion Essential JS 2 menu component will be rendered in the Electron framework. |
| 57 | +## Additional Resources |
78 | 58 |
|
79 | | - ```bash |
80 | | -npm run electron-build |
81 | | - |
82 | | -npm run electron |
83 | | -``` |
| 59 | +For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page. |
0 commit comments