Fireship · @fireship

Native Desktop Apps with Angular and Electron

Uploaded September 21, 2017 · Length 9:43

Native Desktop Apps with Angular and Electron

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.

  1. 0:00

    when you combine angular with the

  2. 0:01

    electron framework it becomes easy to

  3. 0:03

    create native desktop apps that can run

  4. 0:05

    on any platform in this episode we're

  5. 0:08

    going to build a simple timer

  6. 0:09

    application with angular then run that

  7. 0:11

    app natively on Mac OS Windows 10 and

  8. 0:14

    Ubuntu with just a little bit of

  9. 0:16

    configuration we'll be able to build an

  10. 0:17

    executable file for all three of these

  11. 0:19

    platforms while still being able to run

  12. 0:21

    the app in a web browser a large number

  13. 0:23

    of high profile companies use electron

  14. 0:25

    to distribute their software it was

  15. 0:27

    originally developed by github and it's

  16. 0:29

    used by wordpress vs code slack and many

  17. 0:32

    others but before we get started

  18. 0:34

    building the app for this video I just

  19. 0:35

    want to point out that you can get all

  20. 0:37

    the source code at angular firebase comm

  21. 0:39

    or on github and all the links are in

  22. 0:41

    the description so the first thing we're

  23. 0:43

    going to do is install the angular CLI

  24. 0:45

    then create a new app by running ng new

  25. 0:48

    and then we'll CD into that directory

  26. 0:50

    from there we just need to make one

  27. 0:52

    small change to the index.html file in

  28. 0:55

    the source directory you'll notice the

  29. 0:57

    base hrf points to a single slash to

  30. 1:00

    make this work with electron we just

  31. 1:01

    need to add a single period in front of

  32. 1:03

    it from here we're going to install

  33. 1:06

    electron into our development

  34. 1:07

    environment so run npm install electron

  35. 1:09

    flag save dev the next step is to create

  36. 1:13

    a file called main j s and the root of

  37. 1:15

    your angular project main j s is where

  38. 1:18

    you handle all the backend logic for an

  39. 1:20

    electron app so first we're going to

  40. 1:22

    import the app and browser window

  41. 1:24

    objects first we declare a variable win

  42. 1:27

    that defines how the app will look when

  43. 1:29

    the user first opens it on their

  44. 1:31

    operating system so our timer apps going

  45. 1:33

    to be 600 pixels by 600 pixels with a

  46. 1:35

    background color of white and I also

  47. 1:38

    have a logo image file in the assets

  48. 1:40

    folder of my app and just so you know

  49. 1:41

    the underscore dir name is a node.js

  50. 1:44

    variable that refers to the actual

  51. 1:46

    location of a file on this particular

  52. 1:48

    system then the next step is to call

  53. 1:51

    when load URL with the index file for

  54. 1:55

    our app it's important to point out that

  55. 1:56

    we're telling electron to use the

  56. 1:58

    index.html file in our distal der not