© V. Keerti Kotaru 2016

V. Keerti Kotaru, Material Design implementation with AngularJS, 10.1007/978-1-4842-2190-7_8

8. Lists and Alerts

V. Keerti Kotaru

(1)Hyderabad, Andhra Pradesh, India

In this chapter, we will explore some more Angular Material directives and services. We will begin with list and grid list. They are quite effective controls to represent complex data. The controls are easy to use and are highly configurable. They provide flexibility in look-and-feel and functionality.

We will then detail dialog and toast elements that alert and inform data to the user. An application will have a variety of alerting requirements. Some are information only. Certain others are critical and need user attention. The Angular Material elements/directives cater many of these requirements. Adhering to Material Design specifications, they provide efficient controls.

List

List view is a frequently used UI element. Angular Material provides directives which give the list UI and functionality out of the box. See Figure 8-1.

A416608_1_En_8_Fig1_HTML.jpg
Figure 8-1. Angular Material list

Use directives md-listand md-list-itemto create a list. The directive/element md-list is a container of multiple list items. Use md-list-item to create each list item. Consider the following code sample.

<md-list>
        <md-list-item class="md-2-line" ng-repeat="item in superheroes" ng-click="null">
        <img ng-src="{{item.imageUrl}}" class="md-avatar">
        <div class="md-list-item-text" layout="column" >
            <strong>{{item.name}}</strong>
            <div>{{item.category}}</div>
        </div>
    </md-list-item>
</md-list>

Using ng-repeat, we iterate through the array of items (superheroes) on md-list-item. Consider using CSS classes md-2-line or md-3-line. As the name suggests, they define the number of lines of text in each list item. The CSS class adjusts the height of the list item accordingly.

Optionally, we can show an image on each list item. If we show an image, use the following CSS classes .

  1. md-avatar for an image file. It could be a png or jpeg file.

  2. md-avatar-icon for an icon to be used as an image on the list item.

Using the preceding CSS classes , fit the image to the list item (with respect to height and width). Review Figure 8-1, which demonstrates how images fit to the height and width of the list item.

The text part of the list item, titles, description, and so on should be wrapped in any HTML element (say div) with md-list-item-text CSS class applied on it.

Notice ng-click on each md-list-item. As the value provided is null, on click, no action is performed. Nevertheless, we may provide a controller function. Use it to navigate to the details screen after clicking a list item. We may choose to exclude ng-click altogether. If we do so, the list item will not show a highlight on hovering. Moreover, clicking does not generate an animation (like a button click).

If we need to show a paragraph of information in each list item, maybe similar to description text, use md-long-textCSS class. See Figure 8-2.

A416608_1_En_8_Fig2_HTML.jpg
Figure 8-2. List box with long text formatting

The following is another sample with some of these variations.

        <md-list>
            <md-list-item class="md-3-line md-long-text" ng-repeat="item in superheroes">
<!-- no ng-click-->
                <img ng-src="{{item.imageUrl}}" class="md-avatar">
                <div class="md-list-item-text" layout="column" >
                    <strong>{{item.name}}</strong>
                    <div>{{item.category}}</div>
                    <div>Lorem ipsum ... </div>
                </div>
            </md-list-item>
        </md-list>

Further exploring options with lists, we could use a secondary button on a list item. It is aligned to the right end of the row. It could act similar to more action buttons. Consider the following code and Figure 8-3.

A416608_1_En_8_Fig3_HTML.jpg
Figure 8-3. List with secondary action buttons
<md-list>
    <md-list-item class="secondary-button-padding" ng-repeat="item in superheroes" ng-click="buttonClickHandler()">
        <img ng-src="{{item.imageUrl}}" class="md-avatar">    
        <div class="md-list-item-text" layout="column" >            
            <strong>{{item.name}}</strong>
            <span>{{item.category}}</span>
        </div>
        <md-button class="md-secondary" ng-click="secondaryButtonClickHandler()">
           Actions
        </md-button>
    </md-list-item>
</md-list>

On the list item element/directive, using a CSS class secondary-button-padding aligns the secondary button to the right edge of the screen. Another CSS class md-secondary is applied on the button. You may choose to make the whole list item a primary button. If done, the secondary button action will not trigger primary action even though it is part of the row. It will trigger secondary action in isolation. In the sample, if we click anywhere on the list item, it triggers buttonClickHandler (this is a function defined on $scope). If we click the “Actions” button, it triggers secondaryButtonClickHandler in isolation.

Grid List

Grid list is a special representation of data compared to list view. It highlights content better and fits descriptive text and images on each item in the list.

Angular Material provides a grid component, set of directives out of the box. It takes a different approach from ng-grid, which (ngGrid) supports functionalities like sort and filter. Consider this grid as an alternative to list. It is a different and unique depiction of data. Each list item here is represented as a tile. See Figure 8-4.

A416608_1_En_8_Fig4_HTML.jpg
Figure 8-4. Grid list sample

The following is a basic sample.

Consider the following code.

<md-grid-list md-cols="2" md-row-height="300px">
    <md-grid-tile ng-class="item.background" ng-click="null" ng-repeat="item in superheroes">
        <img style="max-width:100px" ng-src="{{item.imageUrl}}" />
        <md-grid-tile-footer layout-padding>
            <span>{{item.category}}</span>
        </md-grid-tile-footer>
        <md-grid-tile-header layout-padding>
            <h2>{{item.name}}</h2>
        </md-grid-tile-header>
    </md-grid-tile>
</md-grid-list>

Grid List Element (md-grid-list)

md-grid-listdirective encapsulates all the elements of a grid list.

  1. Use an attribute "md-cols" to configure number of columns or cells in a row. In the preceding sample, we have two columns.

  2. Consider making the grid responsive. Configure different numbers of columns depending on screen size. There is another example later in the chapter, which demonstrates this behavior.

  3. Configure row height with an attribute md-row-height. In the preceding sample, we set it to 300px. We could set a value in rem or ratio of width and height. For example, 38rem and 3:4 are valid values.

  4. Configure gutter size between tiles with the md-gutter attribute. Provide a value in px (pixels).

Grid Tile Directive ( md-grid-tile)

Each tile/item/cell is represented by a child element/directive md-grid-tile. In the preceding sample, we are iterating through the superheroes array (on scope) to create multiple grid tile elements.

A grid tile may contain the following. These are child elements/directives for a grid tile.

  1. Header: Use md-tile-header for header on the tile. In general, it could be used for showing a title on the tile.

  2. Footer: Use md-tile-footer for footer on the tile. In the sample, we are showing category information on the footer.

  3. Workspace: We could show text or images in a tile. In the sample, we show images of superheroes.

It is not necessary to use all the child elements of md-grid-tile. A tile may contain a header, a footer, both of them, or neither of them. All possible combinations can be used.

On md-grid-tile, consider using attributes md-colspan and md-rowspan. This specifies number of columns or rows a given tile should occupy. This allows defining different sizes for each tile. We may choose to show a bigger first tile. Alternatively, a dynamic grid list layout where each tile’s size is defined by length of the content inside.

The following sample takes a simplistic approach. It marks the beginning of the grid list with a bigger tile. On the first tile, row span value is set to two. See Figure 8-5.

A416608_1_En_8_Fig5_HTML.jpg
Figure 8-5. Grid list with row span on first tile

Consider the following code. Code in boldface uses an expression to identify the first tile and resize to occupy two rows. ng-repeat tracks index of an item while iterating through the list using a variable $index. If the value is 0, set rowspan to 2; for all other tiles set it to 1 (default size).

<md-grid-tile md-rowspan="{{($index===0)?2:1}}"  ng-class="item.background" ng-click="null" ng-repeat="item in superheroes">                                                                                                                          
                <img style="max-width:100px" ng-src="{{item.imageUrl}}" />
Note

md-colspan value should not be greater than md-cols value set on the parent md-grid-list.

Responsive Attributes

Use responsive attributes to let the grid list adapt to different screen sizes. See Figure 8-6 and Figure 8-7.

A416608_1_En_8_Fig6_HTML.jpg
Figure 8-6. Three columns on a large screensize (gt-md)
A416608_1_En_8_Fig7_HTML.jpg
Figure 8-7. Single column and default row span for first tile on a small screen

Consider the following code.

<md-grid-list md-cols-sm="1" md-cols-md="2" md-cols-gt-md="3" md-row-height="16:9">
        <md-grid-tile md-rowspan-gt-sm="{{($index===0)?2:1}}" ng-class="item.background" ng-click="null" ng-repeat="item in superheroes">
        <img style="max-width:100px" ng-src="{{item.imageUrl}}" />


        <md-grid-tile-footer layout-padding>
            <span>{{item.category}}</span>
        </md-grid-tile-footer>
        <md-grid-tile-header layout-padding>
            <h2>{{item.name}}</h2>
        </md-grid-tile-header>    
    </md-grid-tile>                                  
</md-grid-list>

As the boldface code shows, md-cols sets the number of columns to one on a small screen, two on a medium-size screen, and three on a greater-than-medium screen. Also notice that on md-grid-tile, the rowspan logic described previously is applied to greater-than-small screens only. Thus, on a small screen a default value of one is applied for row span.

Alerts and Dialogs

Alerts and dialogs are important UI elements. To the user, they provide information or alert a critical action and allow acceptance of a final confirmation or provide a choice to select from a series of options. We could even show a pop-up window (not a browser window) within the page with any additional content. The service and elements/directives being discussed in this section will help create Material Design style dialog boxes in Angular Material. See Figure 8-8.

A416608_1_En_8_Fig8_HTML.jpg
Figure 8-8. An elaborate Angular Material dialog

Consider the following code . This template has been used in the dialog window.

<script type="text/ng-template" id="dialogTemplate.html">
   <md-dialog>
     <md-toolbar>
         <div class="md-toolbar-tools">
             <h2>Welcome</h2>
         </div>
     </md-toolbar>
     <md-dialog-content class="md-dialog-content">        
            <strong>
             Dialog begins here. Click anywhere outside the dialog to close it.
            </strong>
            <br/>
            <br/>
            <sup>Lorem ipsum …</sup>
     </md-dialog-content>
   </md-dialog>
</script>

The template is referenced as dialogTemplate.html.

md-dialog Element

A dialog is encapsulated in md-dialog element/directive. It may contain one or more child elements/directives.

  1. To show dialog content, use the element/directive md-dialog-content. On it, apply a CSS class md-dialog-content if padding is required.

  2. Group all dialog action buttons (for example, OK, Cancel buttons) in md-dialog-actions element/directive.

  3. These two elements take care of alignment and positioning for the dialog.

  4. Like any other window, for a toolbar and title use md-toolbar element/directive.

The preceding template could be in a separate HTML file. For the sample, it has been included in the index.html page (in a template script) and provided with id "dialogTemplate.html". This template or the dialog is not shown until we explicitly make a call to show.

Inject a service $mdDialog into the controller. Use the show function on the service to show the dialog.

    $mdDialog.show({
        templateUrl: "dialogTemplate.html",
        parent: angular.element(document.body), // dialog is a child element of body
        clickOutsideToClose: true
    });

Notice clickOutsideToClose set to true. If this value is set to false, we might have to add a button to close the dialog (in md-dialog-actions).

The following are certain other configurations we can take advantage of, while showing a dialog.

  1. template: Use template: '<!-- template -->' to provide template as a string instead of linking a template file.

  2. onComplete: function(){} - Use onComplete callback function to run an action after show is complete.

  3. openFrom: "#idOfTheElement" - The animation that depicts opening dialog zooms in from this element. This element could be placed on left, right, center (center is default for the dialog anyway), or any corner of the page.

  4. closeTo: "#idOfTheElement" - The animation that depicts closing dialog zooms out to this element. This element could be placed on left, right, center (default for dialog anyway), or any corner of the page.

Pass Values to the Dialog

Many times, the launching controller will have dynamic values to pass to the dialog. Also, using a separate controller for the dialog will isolate its logic from parent controller. It will be a better separation of concerns. Consider the following code.

$scope.message = "Good Morning";
$mdDialog.show({
    templateUrl: "dialogTemplate.html",
    parent: angular.element(document.body), // alert is a child element of body


    clickOutsideToClose: true,
    locals: {
       aTitle: $scope.message
    },
    controller: function($scope, aTitle){
        $scope.title = aTitle;
    }
});

The "locals" variable can hold one or more value providers. Here we added aTitle to it. And aTitle is injected into the controller. Use value from aTitle on scope. Refer to the following template code to see the scope variable used in the template.

<md-dialog-content class="md-dialog-content">
    <h2>{{title}}</h2>
    <strong>
        Dialog be... <!-- rest of the template as in earlier example -->

Alert Dialog

Alert is used for information purposes and will only contain an OK button to close the dialog.

Consider Figure 8-9 and the following code. This approach allows creating an alert reference and reusing it. We create an alert with the following code. It is not shown to the user yet.

A416608_1_En_8_Fig9_HTML.jpg
Figure 8-9. Simple Angular Material–styled alert box sample
 var aSimpleAlert = $mdDialog
     .alert()
     .title("Welcome")
     .textContent(" This is a simple alert message")
     .ok("Ahaa")
 ;

Use alert function on $mdDialog to create an alert instance. Set title and content of the alert using title and textContent functions, respectively. If an OK button needs to be shown, use the API/function ok to set text for the button.

Show the Alert

Show the alert when needed. It could be used when the user clicks a button or on certain other events that require the alert to be shown.

 $mdDialog.show(aSimpleAlert);

As mentioned, $mdDialog.alert() creates an alert/dialog. The sample uses more API functions (title, textContent, and ok) to configure the dialog. There are more sophisticated API available on an alert object. Consider the following.

  1. htmlContent('<!-- Html template -->'): Unlike textContent API, we can provide HTML templates to this function. Note that ngSanitize module needs to be added as a dependency to use this function.

  2. templateUrl('templates/yourTemplate.html'): Specify a template file for the alert. Template should have alert’s content.

  3. theme('themeName'): Provide a theme name as parameter to apply a custom theme while showing the dialog box.

  4. clickOutsideToClose(true): Passing a value true allows the dialog to close when clicked outside the alert box. Default is false. Hence, an action button to close the dialog is needed.

  5. ariaLabel('a descriptive message'): Sets a string as a description for accessibility requirements. Screen reader/tools use this string.

  6. openFrom("#idOfTheElement"): The animation that depicts opening alert zooms in from this element. This element could be placed on left, right, center (default for the dialog anyway) or any corner of the page.

  7. closeTo("#idOfTheElement"): The animation that depicts closing alert zooms out to this element. This element could be placed on left, right, center (default for the dialog anyway) or any corner of the page.

Hide the Alert

To hide an alert, use $mdDialog.show(alertDialogReference). Consider the following code. It hides the dialog 5 seconds after showing it.

$scope.showSimpleMessage = function(event){
    $mdDialog.show(aSimpleAlert);
    $timeout(function(){
        $scope.hideAlertMessage();
     }, 5000);
};

Confirm Dialog

Confirm allows the user to make a choice. It could be used for warning messages, which allow the user to make a final choice. See Figure 8-10.

A416608_1_En_8_Fig10_HTML.jpg
Figure 8-10. Angular Material–styled confirm dialog

Consider the following code . Similar to alert, we create an object of the confirm dialog. We could reuse it across the controller (whichever is the scope of the object).

var aConfirmDialog = $mdDialog
.confirm()
.parent(angular.element(document.body))
.title("Confirm")
.textContent(" Are you sure to continue?")
.ok("Yes")
.cancel("No")
.openFrom("#left")
;

Create a confirm dialog reference using confirm() function on $mdDialog service. Configure multiple aspects about the dialog.

  1. Set parent using parent() API. The sample sets the whole body element in the HTML as the parent.

  2. Similar to alert, set title and textContent on the confirm dialog.

  3. Unlike alert dialog, confirm has two buttons: OK and Cancel. Set text on the button using ok() and cancel() API.

  4. ariaLabel('a descriptive message'): Sets a string as a description for accessibility requirements. Screen reader/tools use this string.

  5. Use openFrom(elementReference) to open the confirm dialog from given element in the template. The open animations zoom in from this element in the template. It could be placed on left or on right or at any corner of the page.

  6. Use closeTo(elementReference) to close the confirm dialog to a given element in the template. The close animations zoom out to this element in the template. It could be placed on left or on right or at any corner of the page.

  7. theme('themeName'): Provide a theme name as parameter to apply a custom theme while showing the dialog box.

  8. htmlContent('<!-- Html template -->'): Unlike textContent API, we can provide HTML templates to this function. Note that ngSanitize module needs to be added as a dependency to use this function.

  9. templateUrl('templates/yourTemplate.html'): Specify template file for the confirm dialog.

Show the Confirm Dialog

Show the confirm dialog using $mdDialog.show API . However, it returns a promise. As the user makes a selection, it will call success callback or error callback if user selects OK or Cancel button, respectively. Consider the following code.

$mdDialog.show(aConfirmDialog).then(function(result){
    console.log(result + " - User selected yes"); // Success callback on OK click. Output will be "true - User selected yes”.
}, function() {
    console.log("User selected no"); // Error callback on Cancel click
});

Notice success callback accepts a result variable as parameter. When the user selects yes, the result value will be true.

Hide the Dialog Box

To hide the dialog box , use $mdDialog.hide API. Consider the following code. In the sample, we close the dialog automatically after 5 seconds. This is only to demonstrate using hide.

$timeout(function(){
    $mdDialog.hide(aConfirmDialog);
}, 5000);

It resolves the promise with success callback. However, result value will not be true but rather will contain the whole confirm dialog object. This can be used to check if user closed the dialog by clicking OK or it was closed by the alternate logic to hide the dialog.

Toast

Toast is another approach to interact and provide information to the user. More often than not, toast does not obstruct the user’s actions. It pops up a message at a corner and shows the required information. Toast can automatically close itself (disappear) after a few seconds. See Figure 8-11.

A416608_1_En_8_Fig11_HTML.jpg
Figure 8-11. A toast message at the bottom, on a mobile view

It might not suit critical information messages. It is possible that the user might miss the information popped up by the toast. Systems generally will have another view or screen to show alerts shown by toast. However, toast provides a quick non-obstructive way to show the information to the user.

Angular Material service $mdToast encapsulates toast functionality.

To show a simple toast, consider using the following code . It uses $mdToast service, which is injected into the controller.

.controller('toastSampleController', function($scope, $mdToast){
    $scope.showBasicToast = function(){
        $mdToast
            .showSimple("It calls for a toast")
            .then(function(){
                console.log("Done with the toast");


            });
    }

The showSimple function shows a ready-made toast with the given message. The toast will appear at the bottom of the screen.

Notice that the function returns a promise. Promise is resolved once toast disappears. If an action needs to be performed after the toast message, we can write code here. In the sample, we are logging a message ("Done with the toast") to the console.

Basic Customizations

We can customize and reuse a simple toast message. $mdToast exposes an API simple, which returns an object $mdToastPreset. This object stores the configured toast. We could reuse this toast message in the application.

Consider the following code. It creates $mdToastPreset object.

var toastRef = $mdToast
    .simple() // creates a toast message reference ($mdToastPreset)
    .textContent("Welcome to a reusable toast") // set text to be shown on the message.
    .capsule(true); // round edges

These functions are chained, which helps create the whole configuration with one line of JavaScript code. Notice the capsule API. It gives round edges to the toast. See Figure 8-12.

A416608_1_En_8_Fig12_HTML.jpg
Figure 8-12. Toast message styled with round edges

Remember, this toast is not shown yet. Use the following line of code to show it on the screen.

$mdToast
    .show(toast)
    .then(function(){
        console.log("Done with the toast");
    });

Use show function for a preset toast. Similar to the showSimple function, show function too returns a promise, which is resolved as the toast is closed.

Additional Options with simple() API

The following are the additional options while creating a preset toast.

  1. Action: A toast message can have an action button. See Figure 8-13. It has a button “star it” at the end of the row. The user could click or tap on it to perform related action for the toast message. For example, consider a "new message" alert by toast message; the user could star/favorite it using the action.

    A416608_1_En_8_Fig13_HTML.jpg
    Figure 8-13. Toast messages with action defined on it
                toast = $mdToast
                    .simple()
                    .textContent("A new message arrived")
                    .action("Star it!");

    As the user clicks the action button, promise resolved on the show function provides a value "ok" indicating button click.

                $mdToast
                    .show(toast)
                    .then(function(result){
                        console.log(result); // result will be "ok"
                    });
  2. Use highlightAction(true) API to highlight the button.

  3. Use theme("themeName") to show the toast with a different theme (defined by $mdThemingProvider).

Advanced Customizations

Use build API/function to take advantage of advanced options with toast messaging. Similar to simple(), build() function also returns $mdToastPreset object. We could reuse the object across the controller (whichever is the scope of the object). Consider the following code.

 var toastPreset = $mdToast
       .build()
       .template("<md-toast> Advanced Toast</md-toast>")
       .position("top right")
       .hideDelay(10000);


 $mdToast.show(toastPreset);

Here, we are chaining the result to add additional configuration.

Unlike simple() API, build allows configuring a template (instead of just a text message). Use template function to provide HTML for the template. However, the md-toast element/directive is mandatory in the template.

Use templateUrl('url/to/the/template.html') to configure a template file.

Configure a Controller

Toast can have its own controller . Use controller() API and pass a function. It helps better isolation and separation of concerns from the parent controller.

$mdToast
   .build()
   .controller(function($scope){
           // Controller definition
    });

Hide a Toast Message

hideDelay() configures the number of milliseconds the toast should stay on. We can provide a value of 0, which will show the toast forever. In this scenario, create an action button to close the toast. The action button needs to be created in the template.

To close the toast, use $mdToast.hide(toastPresetObject). Add this line in a controller function, which is called upon clicking the action button .

Consider the following code.

 var toastPreset = $mdToast
       .build()
       .template("<md-toast> <strong flex='85'> <sup>Highly </sup>advanced toast </strong> <md-button ng-click='closeToast()'>Close </md-button></md-toast>")
        .hideDelay(0)
        .controller(function($scope, $mdToast){
             $scope.closeToast = function(){
                 $mdToast.hide(toastPreset);
             };
         });


$mdToast.show(toastPreset);

Position a Toast Message

Position()API allows configuring the position of the toast on the page. Possible values are top, left, right, bottom. We could use a combination of these values, that is, "top left", "bottom right", and so on. See Figure 8-14 for the toast positioned top-right.

A416608_1_En_8_Fig14_HTML.jpg
Figure 8-14. Position a toast message

However, on a sm screen (small) it resets the position to bottom. This fits better with small screens. See Figure 8-15.

A416608_1_En_8_Fig15_HTML.jpg
Figure 8-15. On a mobile view, toast positioned at the bottom

However, if you need to show it at a particular position on all screen sizes, use the following approach. Let that position be "top right" all the time or in the middle of the page, next to the element the user is interacting with.

Use parent() api/function and set a particular element on the HTML page as the parent for the toast. That enforces the toast shown at that element’s position all the time.

Consider the following sample. This shows toast in the div element, which is in the middle of a page, in the workspace.

<div id="advancedButton">                
  <md-button ng-click="showAdvCustomizedShow()">Advanced Toast</md-button>
 </div>


var toastPreset = $mdToast
         .build()
         .position("top right")
         .parent(angular.element(document.getElementById("advancedButton")))
         .template("<md-toast> <strong> <sup>Highly </sup>advanced toast </strong></md-toast>")
         .hideDelay(0);


$mdToast.show(toastPreset);

The div element has an id "advancedButton". It is selected in the JavaScript code with document.getElementById() function . The selected element is passed as a parameter to parent() (for toast) function.

Show with Options

Consider using show function without a toastPreset. It is best suited when toast references are not reused.

$mdToast.show({
    position: "top right",
    parent: angular.element(document.getElementById("advancedButton")),
    template: "<md-toast> <strong flex='85'><sup>Highly </sup>advanced toast </strong> <md-button ng-click='closeToast()'>Close </md-button></md-toast>",
    hideDelay: 0,
    locals: {
        dynamicValue: parentVal
    },
    controller: function($scope, $mdToast, dynamicValue){
        console.log(dynamicValue);
        $scope.closeToast = function(){
            $mdToast.hide(toastPreset);
        };
    }
});
Note

Similar to alert dialogs, a dynamic value can be passed from parent controller using locals. The key value pairs in locals are injected into the controller as a value type.

Summary

This chapter details two important data representations in any web application: list and grid list. We start by exploring directives md-list and md-list-item for creating a list view. We discuss configuring and taking advantage of variations in the list view. Depending on the data that need to be represented onscreen, we could take advantage of CSS styling to show a two-line or three-line view of the control. We go through options to show even larger description (of a record). We also learn creating action buttons on list items.

Grid list represents data that are more complex and provides a different perspective. We explore md-grid-list and md-grid-tile elements/directives. We explore nuances of creating a set number of columns in a grid, configuring size, alignment, and so on. We also look at responsive attributes and making the grid adaptive to the screen size.

After data representation, we start exploring alerting or showing dialog boxes with Angular Material elements/directives. At first, we look at creating a dialog pop-up using md-dialog element/directive. We explore showing alerts for warning and information messages. We use $mdDialog service as well. We also go through using confirm dialogs.

Finally, we look at toast messages. Toast messages are more often than not used for information-only messages. We look at using $mdToast service and md-toast element/directive in the template. We begin by making use of ready-made API for creating a simple toast message. We also look at configuring and customizing the toast messages.

References

For Angular Material documentation use http://material.angularjs.org

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144