As part of my series on learning Angular, I am checking out Angular Material, a cool library for implementing Googles Material Design with Angular, come along and check it out !
Note : this is some intermediate Angular stuff, check out my previous posts if you are just getting started:
Also Note : Change is coming… Angular 2 is just around the corner, but for the time being we’ll be working with Angular and Angular Material 1 since they are well documented/stable
See the Pen Angular Material Hello World by Eugenio - Keno - Leon (@k3no) on CodePen.
And there you have it sir, the very simple but ubiquitous cat card component, what did we learn ? couple of things:
In General :
Layouts are a huge part of what makes a front end library useful, let’s look at what Angular Materials has to offer.
See the Pen Angular Material Layout by Eugenio - Keno - Leon (@k3no) on CodePen.
Lessons learned ? Angular Material builds on top of flexbox via directives to specify your layout, sounds a little complicated, but in reality ( after a bit of trial and error), it goes like this:
Like any other grid system ( think Bootstrap) there are specific breakpoints for different devices and a host of other niceties to center, add padding, hide, order etc,etc, a good way to get into them is checking the very nice documentation:
Since Layouts are such a big part of development, let’s dig deeper.
See the Pen Angular Material Complex Layout by Eugenio - Keno - Leon (@k3no) on CodePen.
So like bootstrap, you concatenate or chain options to both the layout container and the individual content blocks to affect display ( following flexbox conventions ), only here you do it with directives instead of classes, all the extra options,troubleshooting and details are explained in the very concise documentation.
Now that we have a decent grasp of the basics ( or so I hope), let’s explore more interactive elements, let’s start with an autocomplete:
See the Pen Angular Material Autocomplete by Eugenio - Keno - Leon (@k3no) on CodePen.
A super minimal example of autocomplete, note I am also using googles material icon library, in a nutshell, the autocomplete provides handles for expressions in the model and options (extra directives) for customizing your autocomplete, if you get stuck or want to implement a real world autocomplete, consult the docs…
Feeling a little more confident, so let’s try adding more than one directive inside a layout to up the ante.
See the Pen Angular Material Multiple Directives + Layout by Eugenio - Keno - Leon (@k3no) on CodePen.
And there you have it, a very,very,very simple semi functional ( I left out the model), but practical Angular Material App.
Directives Used:
Angular Material is a powerful,complex and extensive companion to the Angular Framework, I tried my best to cover all the bases, but I left a lot of things out which hopefully I’ll cover in a second post, I hope this serves you as a gentle introduction to Angular Material.
Best,
Keno