Thursday, February 9, 2017

Angular Material - Cards

md-card, an Angular Directive, is a container directive and is used to draw cards in angularjs application. Following are the angular directives and classes used in md-card.

S.N.Directive/Class & Description
1<md-card-header>
Header for the card, holds avatar, text and squared image.
2<md-card-avatar>
Card avatar.
3md-user-avatar
Class for user image.
4<md-icon>
Icon directive.
5<md-card-header-text>
Contains elements for the card description.
6md-title
Class for the card title.
7md-subhead
Class for the card sub header.
8<img>
Image for the card.
9<md-card-title>
Card content title.
10<md-card-title-text>
Card Title text container.
11md-headline
Class for the card content title.
12md-subhead
Class for the card content sub header.
13<md-card-title-media>
Squared image within the title.
14md-media-sm
Class for small image.
15md-media-md
Class for medium image.
16md-media-lg
Class for large image.
17<md-card-content>
Card content.
18md-media-xl
Class for extra large image.
19<md-card-actions>
Card actions.
20<md-card-icon-actions>
Icon actions.

Example

The following example showcases the use of md-card directive to showcase use of card classes.
am_cards.htm
<html lang="en" >
   <head>
      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
      <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
      <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
      <script language="javascript">
         angular
            .module('firstApplication', ['ngMaterial'])
            .controller('cardController', cardController);

         function cardController ($scope) {            
         }  
      </script>      
   </head>
   <body ng-app="firstApplication">  
      <md-card>
         <img ng-src="html5-mini-logo.jpg" class="md-card-image" alt="Learn HTML5">
         <md-card-header>
            <md-card-avatar>
               <img class="md-user-avatar" src="html5-mini-logo.jpg">
            </md-card-avatar>
            <md-card-header-text>
               <span class="md-title">HTML5</span>
               <span class="md-subhead">Learn HTML5 @TutorialsPoint.com</span>
            </md-card-header-text>
         </md-card-header>
         <md-card-title>
            <md-card-title-text>
               <span class="md-headline">HTML5</span>
            </md-card-title-text>
         </md-card-title>
         <md-card-actions layout="row" layout-align="start center">
            <md-button>Download</md-button>
            <md-button>Start</md-button>
            <md-card-icon-actions>
               <md-button class="md-icon-button" aria-label="icon">
                  <md-icon class="material-icons">add</md-icon>
               </md-button>
            </md-card-icon-actions>
         </md-card-actions>
         <md-card-content>
            <p>HTML5 is the next major revision of the HTML standard superseding HTML 4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring and presenting content on the World Wide Web.</p>
            <p>HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).</p>
            </p>The new standard incorporates features like video playback and drag-and-drop that have been previously dependent on third-party browser plug-ins such as Adobe Flash, Microsoft Silverlight, and Google Gears.</p>
         </md-card-content>
      </md-card>
   </body>
</html>

Result

Verify the result.

2 comments: