Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Create Angular 2 Mobile Card based layouts with Ionic 2

    Mike HartingtonMike Hartington

    Cards have become a common way to handle layout and display information in a easy-to-understand format. Ionic offers utility components that make creating cards straightforward. These components, like ion-card, ion-card-content, and ion-card-header are included in the framework to speed up the development process. There's no JavaScript behind these components, they're really just css driven.

    angularAngular
    2 - 6
    ionicIonic
    Code

    Code

    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    Transcript

    Transcript

    00:01 With the detail of our user being displayed in the detail page, we can start to use a card layout to better organize this information. A card is made up of a few components, an outer ion card wrapper, an inner ion card header, and then another inner ion card content.

    00:25 We can also reuse ion items inside of our card as well. For this card, we'll start off with an ion item instead of an ion card header. Inside of the item, we'll render the user's first name and the user's last name.

    00:42 We'll add an ion avatar, and place it on the left side of the item. Inside of the avatar, we'll add an image, and bind its source to the user's large image. With this item finished up, we'll use the ion card content to create a section of the card that has a little bit of padding. We'll add a few more ion items. Inside of the first one, we'll set up our bindings for the user's location.

    01:22 We'll also go ahead and add an ion icon to this item. The icon can be positioned on the left or the right side using the item-left or item-right attribute. Let's go ahead and fill out these last two ion items with the user's phone number and the user's email address.

    01:49 Now, when we save, we'll have the information displayed in a formatted card. Now, a nice thing about the ion card is that it has no built-in padding. This is why we use the ion card content for the main block of information. Since there's no padding, this means that you can do full background images with just a simple image tag.

    Discuss

    Discuss