Fireship · @fireship
Native Desktop Apps with Angular and Electron
Uploaded September 21, 2017 · Length 9:43
Summary
build native desktop apps with angular and electron frameworks for mac os windows and ubuntu
- angular desktop apps
- electron framework
- native desktop applications
- angular electron tutorial
- desktop app development
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
when you combine angular with the
- 0:01
electron framework it becomes easy to
- 0:03
create native desktop apps that can run
- 0:05
on any platform in this episode we're
- 0:08
going to build a simple timer
- 0:09
application with angular then run that
- 0:11
app natively on Mac OS Windows 10 and
- 0:14
Ubuntu with just a little bit of
- 0:16
configuration we'll be able to build an
- 0:17
executable file for all three of these
- 0:19
platforms while still being able to run
- 0:21
the app in a web browser a large number
- 0:23
of high profile companies use electron
- 0:25
to distribute their software it was
- 0:27
originally developed by github and it's
- 0:29
used by wordpress vs code slack and many
- 0:32
others but before we get started
- 0:34
building the app for this video I just
- 0:35
want to point out that you can get all
- 0:37
the source code at angular firebase comm
- 0:39
or on github and all the links are in
- 0:41
the description so the first thing we're
- 0:43
going to do is install the angular CLI
- 0:45
then create a new app by running ng new
- 0:48
and then we'll CD into that directory
- 0:50
from there we just need to make one
- 0:52
small change to the index.html file in
- 0:55
the source directory you'll notice the
- 0:57
base hrf points to a single slash to
- 1:00
make this work with electron we just
- 1:01
need to add a single period in front of
- 1:03
it from here we're going to install
- 1:06
electron into our development
- 1:07
environment so run npm install electron
- 1:09
flag save dev the next step is to create
- 1:13
a file called main j s and the root of
- 1:15
your angular project main j s is where
- 1:18
you handle all the backend logic for an
- 1:20
electron app so first we're going to
- 1:22
import the app and browser window
- 1:24
objects first we declare a variable win
- 1:27
that defines how the app will look when
- 1:29
the user first opens it on their
- 1:31
operating system so our timer apps going
- 1:33
to be 600 pixels by 600 pixels with a
- 1:35
background color of white and I also
- 1:38
have a logo image file in the assets
- 1:40
folder of my app and just so you know
- 1:41
the underscore dir name is a node.js
- 1:44
variable that refers to the actual
- 1:46
location of a file on this particular
- 1:48
system then the next step is to call
- 1:51
when load URL with the index file for
- 1:55
our app it's important to point out that
- 1:56
we're telling electron to use the
- 1:58
index.html file in our distal der not


