O'Reilly logo

Building Cross-Platform Desktop Applications with Electron by Muhammed Jasim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a database service

Create a new Angular service inside the src folder and name it app.service.ts. This service will do all operations and will serve the data to the UI component directly from the database. Here, webpages can directly access the database using this service. Add the following content into the service:

import {  Injectable  } from '@angular/core'; import * as mysql from 'mysql'; const connection = mysql.createConnection({   host: 'localhost',   user: 'root',   password: 'password', // Your database password  database: 'customer_manager' }); @Injectable() export class AppService { }

Use your database username and password to create the MySQL connection object. Update the preceding Angular service template with real database ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required