Fireship · @fireship

Angular in 100 Seconds

Uploaded September 9, 2020 · Length 2:00

Angular in 100 Seconds

Summary

angular tutorial for beginners: cli, components, dependency injection, and more

  • angular
  • typescript
  • ui framework
  • component-based
  • dependency injection

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    angular a typescript-based framework for

  2. 0:02

    building user interfaces

  3. 0:04

    it was developed at google and released

  4. 0:05

    in 2016 as the sequel to angularjs

  5. 0:08

    as an angular developer you hit the

  6. 0:10

    ground running with its extremely

  7. 0:11

    powerful cli tool

  8. 0:13

    when you generate your initial

  9. 0:14

    application it comes pre-configured with

  10. 0:16

    routing

  11. 0:16

    a testing framework and your favorite

  12. 0:18

    style preprocessor in addition

  13. 0:20

    the magic ng add command can turn your

  14. 0:22

    app into a progressive web app

  15. 0:23

    add server-side rendering firebase

  16. 0:25

    support and do a whole bunch of other

  17. 0:27

    cool stuff

  18. 0:28

    but at its core angular is just a

  19. 0:30

    component-based ui library i can create

  20. 0:32

    a component with the cli

  21. 0:33

    and if we go into its typescript file

  22. 0:35

    you'll notice the component decorator

  23. 0:36

    which makes this typescript class a

  24. 0:38

    component any properties on this class

  25. 0:40

    are considered reactive state

  26. 0:41

    and when their values change the

  27. 0:43

    component will re-render the ui

  28. 0:44

    for example we can bind the property to

  29. 0:47

    html using double braces in the template

  30. 0:49

    from there we can add a button that

  31. 0:51

    increments this value every time it's

  32. 0:53

    clicked

  33. 0:53

    we add the event name on the left side

  34. 0:55

    in parentheses then an expression

  35. 0:57

    on the right side in this case it points

  36. 0:58

    to a method in our class

  37. 1:00

    each time the button is clicked it calls

  38. 1:01

    the method which changes the state

  39. 1:03

    and re-renders the ui angular also has a

  40. 1:06

    variety of directives for building

  41. 1:07

    complex templates

  42. 1:08

    use ngf to handle conditional logic or

  43. 1:11

    if you have an iterable value

  44. 1:12

    use ng4 to loop over it but where

  45. 1:15

    angular really excels is handling

  46. 1:16

    complexity and one of its primary tools

  47. 1:18

    for doing so is called dependency

  48. 1:20

    injection

  49. 1:21

    when your app grows to hundreds of

  50. 1:22

    components you'll likely need a way to

  51. 1:24

    share data and functionality between

  52. 1:25

    them we can take our component logic

  53. 1:27

    here and extract it into a service which

  54. 1:29

    can be treated as a global singleton

  55. 1:31

    throughout the application

  56. 1:32

    now any component that wants to use this

  57. 1:34

    state or logic can simply add this class

  58. 1:36

    to its constructor

  59. 1:37

    the end result is a simple and reliable

  60. 1:39

    way to compose complex applications

  61. 1:42

    as a developer you can always count on a

  62. 1:44

    consistent experience between projects

  63. 1:46

    and minimal decision fatigue this has

  64. 1:47

    been angular in 100 seconds

  65. 1:49

    if you want to see more short videos

  66. 1:50

    like this make sure to like and

  67. 1:52

    subscribe and check out a ton of

  68. 1:53

    advanced angular content on fireship io

  69. 1:55

    thanks for watching

  70. 1:56

    and i will see you in the next one