⚠️ This lesson is retired and might contain outdated information.

Create Angular 2 Mobile Card based layouts with Ionic 2

Mike Hartington
InstructorMike Hartington
Share this video with your friends

Social Share Links

Send Tweet
Published 7 years ago
Updated 2 months ago

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.

[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.

egghead
egghead
~ 15 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today