Fireship · @fireship

Angular CDK Data Tables

Uploaded July 19, 2018 · Length 10:38

Angular CDK Data Tables

Summary

Building a custom data table with Angular CDK and Bootstrap 4, including reactive behavior and styling.

  • angular cdk data table
  • custom data table
  • reactive table
  • angular bootstrap 4
  • cdk table styling

Transcript preview

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

  1. 0:00

    [Music]

  2. 0:06

    what if there is a way that you could

  3. 0:08

    capture all the benefits of annular

  4. 0:09

    material but customize the behavior and

  5. 0:11

    styling in an unaffiliated way well

  6. 0:14

    that's exactly what angular's component

  7. 0:16

    development kit does in today's video

  8. 0:18

    you'll learn how to build a reactive cdk

  9. 0:20

    data table that implements its own

  10. 0:21

    custom behaviors and also uses bootstrap

  11. 0:24

    4 for its CSS styling if you're new to

  12. 0:27

    the channel make sure to LIKE and

  13. 0:28

    subscribe and the code for this video is

  14. 0:30

    produced by Zack DeRose who is a senior

  15. 0:32

    team lead working on angular over at

  16. 0:34

    Swamp Fox Inc

  17. 0:36

    make sure to check out his full article

  18. 0:37

    on medium because it goes into some

  19. 0:39

    advanced stuff that I don't cover here

  20. 0:40

    such as searching sorting and applying

  21. 0:42

    styles on a cell-by-cell basis I'm

  22. 0:45

    starting out from the state regular

  23. 0:47

    angular 6 app and the first thing I'll

  24. 0:49

    do is install the component development

  25. 0:50

    kit which is at angular slash cdk then

  26. 0:54

    I'll generate a component called table

  27. 0:56

    from there I'll jump over to the app

  28. 0:58

    module and we'll want to import the data

  29. 1:01

    table from angular cdk then add the cdk

  30. 1:05

    table module to the imports array the

  31. 1:07

    first table we'll build is pretty basic

  32. 1:09

    and ugly but what it's doing under the

  33. 1:11

    hood is pretty powerful

  34. 1:12

    and without the cdk this would take a

  35. 1:14

    lot more code than it does in this video

  36. 1:16

    I'll be working with some dummy data

  37. 1:18

    throughout this video which I have saved

  38. 1:20

    in this data Ts file first we have an

  39. 1:23

    array of column names which just define

  40. 1:25

    the names of the columns in the table

  41. 1:27

    and then we have the actual data which

  42. 1:29

    is a map of various heroes and each hero

  43. 1:33

    has a set of properties that match these

  44. 1:35

    column names so basically this simulates

  45. 1:37

    some initial data that you might pull

  46. 1:39

    from a back-end database or API now

  47. 1:42

    let's jump into the component and start

  48. 1:44

    putting together this table I'm going to

  49. 1:47

    go pretty slow through this code because

  50. 1:48

    I want to talk about behavior subjects

  51. 1:50

    and observables because they're very

  52. 1:52

    powerful structures when working with

  53. 1:54

    tables a behavior subject is really

  54. 1:56

    useful when you have a value that you

  55. 1:58

    want to manually change over time they