Angular Material – Toasts ”; Previous Next The Angular Material provides various special methods to show unobtrusive alerts to the users. It also provides a term toast for them. The $mdToast service is used to show toasts. Example The following example shows the use of toasts. am_toasts.htm Live Demo <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(”toastController”, toastController); function toastController ($scope, $mdToast, $document) { $scope.showToast1 = function() { $mdToast.show ( $mdToast.simple() .textContent(”Hello World!”) .hideDelay(3000) ); }; $scope.showToast2 = function() { var toast = $mdToast.simple() .textContent(”Hello World!”) .action(”OK”) .highlightAction(false); $mdToast.show(toast).then(function(response) { if ( response == ”ok” ) { alert(”You clicked ”OK”.”); } }); } } </script> </head> <body ng-app = “firstApplication”> <div id = “toastContainer” ng-controller = “toastController as ctrl” layout = “row” ng-cloak> <md-button ng-click = “showToast1()”>Show Simple Alert</md-button> <md-button ng-click = “showToast2()”>Show Alert with callback</md-button> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Category: angular Material
Angular Material – Virtual Repeat ”; Previous Next The md-virtual-repeat-container is the scroll container for the md-virtual-repeat component. Attributes The following table lists out the parameters and description of the different attributes of md-virtual-repeat-container. Sr.No Parameter & Description 1 md-top-index Binds the index of the item that is at the top of the scroll container to $scope. It can both read and set the scroll position. 2 md-orient-horizontal Determines whether the container should scroll horizontally (defaults to orientation and scrolling vertically). 3 md-auto-shrink When present, the container will shrink to fit the number of items when that number is less than its original size. 4 md-auto-shrink-min Minimum number of items that md-auto-shrink will shrink to (default: 0). md-virtual-repeat Virtual repeat is a substitute for ng-repeat to renders only enough html elements to fill the container and reuse them when the user scrolls. Attributes The following table lists out the parameters and description of the different attributes of md-virtual-repeat. Sr.No Parameter & Description 1 md-item-size The height or width of the repeated elements (which must be identical for each element). This is optional. This attempts to read the size from the dom if missing, but still assumes that all repeated nodes have same height or width. 2 md-extra-name Evaluates to an additional name to which the current iterated item can be assigned on the repeated scope (needed for use in md-autocomplete). 3 md-on-demand When present, treats the md-virtual-repeat argument as an object that can fetch rows rather than an array.This object must implement the following interface with two (2) methods − getItemAtIndex − function(index) [object] – The item at that index or null if it is not yet loaded (it should start downloading the item in that case). getLength − function() [number] – The data length to which the repeater container should be sized. Ideally, when the count is known, this method should return it. Otherwise, return a higher number than the currently loaded items to produce an infinite-scroll behavior. Example The following example show the use of virtual repeat. am_virtualrepeat.htm Live Demo <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”> <style> .vrepeatContainer #horizontal-container { height: 100px; width: 830px; } .vrepeatContainer #vertical-container { height: 292px; width: 400px; } .vrepeatContainer .repeated-item-horizontal { border-right: 1px solid #ddd; box-sizing: border-box; display: inline-block; height: 84px; padding-top: 35px; text-align: center; width: 50px; } .vrepeatContainer .repeated-item-vertical { border-bottom: 1px solid #ddd; box-sizing: border-box; height: 40px; padding-top: 10px; } .vrepeatContainer md-content { margin: 16px; } .vrepeatContainer md-virtual-repeat-container { border: solid 1px grey; } </style> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”vrepeatController”, vrepeatController); function vrepeatController ($scope) { this.items = []; for (var i = 0; i < 1000; i++) { this.items.push(i); } } </script> </head> <body ng-app = “firstApplication”> <div class = “vrepeatContainer” ng-controller = “vrepeatController as ctrl” ng-cloak> <md-content layout = “column”> <h2>Horizontal Repeat</h2> <md-virtual-repeat-container id = “horizontal-container” md-orient-horizontal> <div md-virtual-repeat = “item in ctrl.items” class = “repeated-item-horizontal” flex> {{item}} </div> </md-virtual-repeat-container> <h2>Vertical Repeat</h2> <md-virtual-repeat-container id = “vertical-container”> <div md-virtual-repeat = “item in ctrl.items” class = “repeated-item-vertical” flex> {{item}} </div> </md-virtual-repeat-container> </md-content> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Angular Material – Layouts
Angular Material – Layouts ”; Previous Next Layout Directive Layout directive on a container element is used to specify the layout direction for its children. Following are the assignable values for the Layout Directive − row − Items are arranged horizontally with max-height = 100% and max-width is the width of the items in the container. column − Items are arranged vertically with max-width = 100% and max-height is the height of the items in the container. For responsive design such as layout to be automatically changed depending upon the device screen size, the layout APIs listed in the following table can be used to set the layout direction for devices with view widths. Sr.No API & Device width when breakpoint overrides default 1 layout Sets default layout direction unless overridden by another breakpoint. 2 layout-xs width < 600px 3 layout-gt-xs width >= 600px 4 layout-sm 600px <= width < 960px 5 layout-gt-sm width >= 960px 6 layout-md 960px <= width < 1280px 7 layout-gt-md width >= 1280px 8 layout-lg 1280px <= width < 1920px 9 layout-gt-lg width >= 1920px 10 layout-xl width >= 1920px Example The following example shows the use of layout directive and also the uses of layout. am_layouts.htm Live Demo <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”> <style> .box { color:white; padding:10px; text-align:center; border-style: inset; } .green { background:green; } .blue { background:blue; } </style> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”layoutController”, layoutController); function layoutController ($scope) { } </script> </head> <body ng-app = “firstApplication”> <div id = “layoutContainer” ng-controller = “layoutController as ctrl” style = “height:100px;” ng-cloak> <div layout = “row” layout-xs = “column”> <div flex class = “green box”>Row 1: Item 1</div> <div flex = “20” class = “blue box”>Row 1: Item 2</div> </div> <div layout = “column” layout-xs = “column”> <div flex = “33” class = “green box”>Column 1: item 1</div> <div flex = “66” class = “blue box”>Column 1: item 2</div> </div> </div> </body> </html> Result Verify the result. Flex Directive The flex directive on a container element is used to customize the size and position of the elements. It defines the way how the element is to adjust its size with respect to its parent container and the other elements within the container. Following are the assignable values for the flex directive − multiples of 5 − 5, 10, 15 … 100 33 − 33% 66 − 66% Example The following example shows the use of the flex directive and also the uses of flex. am_flex.htm Live Demo <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”> <style> .box { color:white; padding:10px; text-align:center; border-style: inset; } .green { background:green; } .blue { background:blue; } </style> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”layoutController”, layoutController); function layoutController ($scope) { } </script> </head> <body ng-app = “firstApplication”> <div id = “layoutContainer” ng-controller = “layoutController as ctrl” layout = “row” style = “height:100px;” ng-cloak layout-wrap> <div flex = “30” class = “green box”> [flex = “30”] </div> <div flex = “45” class = “blue box”> [flex = “45”] </div> <div flex = “25” class = “green box”> [flex = “25”] </div> <div flex = “33” class = “green box”> [flex = “33”] </div> <div flex = “66” class = “blue box”> [flex = “66”] </div> <div flex = “50” class = “blue box”> [flex = “50”] </div> <div flex class = “green box”> [flex] </div> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Angular Material – Icons
Angular Material – Icons ”; Previous Next The md-icon, an Angular directive, is a component to show vector-based icons in application. It supports icon fonts and SVG icons also apart from using the Google Material Icons. Attributes The following table lists out the parameters and description of the different attributes of md-icon. Sr.No Parameter & Description 1 * md-font-icon This is the string name of CSS icon associated with the font-face, which will be used to render the icon. Requires the fonts and the named CSS styles to be preloaded. 2 * md-font-set This is the CSS style name associated with the font library, which will be assigned as the class for the font-icon ligature. This value may also be an alias that is used to lookup the classname; internally use $mdIconProvider.fontSet(<alias>) to determine the style name. 3 * md-svg-src This is the String URL (or expression) used to load, cache, and display an external SVG. 4 * md-svg-icon This is the string name used for lookup of the icon from the internal cache; interpolated strings or expressions may also be used. Specific set names can be used with the syntax <set name>:<icon name>. To use icon sets, developers are required to pre-register the sets using the $mdIconProvider service. 5 aria-label This labels icon for accessibility. If an empty string is provided, icon will be hidden from accessibility layer with aria-hidden = “true”. If there”s no aria-label on the icon nor a label on the parent element, a warning will be logged to the console. 6 alt This labels icon for accessibility. If an empty string is provided, icon will be hidden from accessibility layer with aria-hidden = “true”. If there”s no alt on the icon nor a label on the parent element, a warning will be logged to the console. Example The following example shows the use of md-icons directive and also the uses of icons. am_icons.htm Live Demo <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”> <style> .iconDemo .glyph { border-bottom: 1px dotted #ccc; padding: 10px 0 20px; margin-bottom: 20px; } .iconDemo .preview-glyphs { display: flex; flex-direction: row; } .iconDemo .step { flex-grow: 1; line-height: 0.5; } .iconDemo .material-icons.md-18 { font-size: 18px; } .iconDemo .material-icons.md-24 { font-size: 24px; } .iconDemo .material-icons.md-36 { font-size: 36px; } .iconDemo .material-icons.md-48 { font-size: 48px; } .iconDemo .material-icons.md-dark { color: rgba(0, 0, 0, 0.54); } .iconDemo .material-icons.md-dark.md-inactive { color: rgba(0, 0, 0, 0.26); } .iconDemo .material-icons.md-light { color: white; } .iconDemo .material-icons.md-light.md-inactive { color: rgba(255, 255, 255, 0.3); } </style> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”iconController”, iconController); function iconController ($scope) { var iconData = [ {name: ”accessibility” , color: “#777″ }, {name: ”question_answer”, color: “rgb(89, 226, 168)” }, {name: ”backup” , color: “#A00″ }, {name: ”email” , color: “#00A” } ]; $scope.fonts = [].concat(iconData); $scope.sizes = [ {size:”md-18″,padding:0}, {size:”md-24″,padding:2}, {size:”md-36″,padding:6}, {size:”md-48″,padding:10} ]; } </script> </head> <body ng-app = “firstApplication”> <div id = “iconContainer” class = “iconDemo” ng-controller = “iconController as ctrl” ng-cloak> <div class = “glyph” ng-repeat = “font in fonts” layout = “row”> <div ng-repeat = “it in sizes” flex layout-align = “center center” style = “text-align: center;” layout = “column”> <div flex></div> <div class = “preview-glyphs”> <md-icon ng-style = “{color: font.color}” aria-label = “{{ font.name }}” class = “material-icons step” ng-class = “it.size”> {{ font.name }} </md-icon> </div> </div> </div> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Discuss Angular Material ”; Previous Next Angular Material is a UI component library for Angular JS developers. Angular Material components help in constructing attractive, consistent, and functional web pages and web applications while adhering to modern web design principles like browser portability, device independence, and graceful degradation. It helps in creating faster, beautiful, and responsive websites. It is inspired by the Google Material Design. Print Page Previous Next Advertisements ”;
Angular Material – Grids
Angular Material – Grids ”; Previous Next The md-grid-list, an Angular directive, is a component for laying out content for varying screen sizes. A grid has 12 columns in the desktop size screen, 8 in the tablet size screen, and 4 in the phone size screen, where each size have predefined margins and gutters. Cells are laid out in sequential manner in a row, in the order they are defined. Attributes The following table lists out the parameters and description of the different attributes of md-grid-list. Sr.No Parameter & Description 1 * md-cols This is for the number of columns in the grid. 2 * md-row-height One of CSS length − Fixed height rows (eg. 8px or 1rem). {width}:{height} − Ratio of width to height (eg. md-row-height = “16:9”). “fit” − Height will be determined by subdividing the available height by the number of rows. 3 md-gutter The amount of space between tiles in CSS units (default 1px). 4 md-on-layout Expression to evaluate after layout. Event object is available as $event, and contains performance information. Example The following example shows the use of the md-grid-list directive and also the uses of grid. am_grid.htm Live Demo <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(”gridController”, gridController); function gridController ($scope) { var COLORS = [ ”#ffebee”, ”#ffcdd2”, ”#ef9a9a”, ”#e57373”, ”#ef5350”, ”#f44336”, ”#e53935”, ”#d32f2f”, ”#c62828”, ”#b71c1c”, ”#ff8a80”, ”#ff5252”, ”#ff1744”, ”#d50000”, ”#f8bbd0”, ”#f48fb1”, ”#f06292”, ”#ec407a”, ”#e91e63”, ”#d81b60”, ”#c2185b”, ”#ad1457”, ”#880e4f”, ”#ff80ab”, ”#ff4081”, ”#f50057”, ”#c51162”, ”#e1bee7”, ”#ce93d8”, ”#ba68c8”, ”#ab47bc”, ”#9c27b0”, ”#8e24aa”, ”#7b1fa2”, ”#4a148c”, ”#ea80fc”, ”#e040fb”, ”#d500f9”, ”#aa00ff”, ”#ede7f6”, ”#d1c4e9”, ”#b39ddb”, ”#9575cd”, ”#7e57c2”, ”#673ab7”, ”#5e35b1”, ”#4527a0”, ”#311b92”, ”#b388ff”, ”#7c4dff”, ”#651fff”, ”#6200ea”, ”#c5cae9”, ”#9fa8da”, ”#7986cb”, ”#5c6bc0”, ”#3f51b5”, ”#3949ab”, ”#303f9f”, ”#283593”, ”#1a237e”, ”#8c9eff”, ”#536dfe”, ”#3d5afe”, ”#304ffe”, ”#e3f2fd”, ”#bbdefb”, ”#90caf9”, ”#64b5f6”, ”#42a5f5”, ”#2196f3”, ”#1e88e5”, ”#1976d2”, ”#1565c0”, ”#0d47a1”, ”#82b1ff”, ”#448aff”, ”#2979ff”, ”#2962ff”, ”#b3e5fc”, ”#81d4fa”, ”#4fc3f7”, ”#29b6f6”, ”#03a9f4”, ”#039be5”, ”#0288d1”, ”#0277bd”, ”#01579b”, ”#80d8ff”, ”#40c4ff”, ”#00b0ff”, ”#0091ea”, ”#e0f7fa”, ”#b2ebf2”, ”#80deea”, ”#4dd0e1”, ”#26c6da”, ”#00bcd4”, ”#00acc1”, ”#0097a7”, ”#00838f”, ”#006064”, ”#84ffff”, ”#18ffff”, ”#00e5ff”, ”#00b8d4”, ”#e0f2f1”, ”#b2dfdb”, ”#80cbc4”, ”#4db6ac”, ”#26a69a”, ”#009688”, ”#00897b”, ”#00796b”, ”#00695c”, ”#a7ffeb”, ”#64ffda”, ”#1de9b6”, ”#00bfa5”, ”#e8f5e9”, ”#c8e6c9”, ”#a5d6a7”, ”#81c784”, ”#66bb6a”, ”#4caf50”, ”#43a047”, ”#388e3c”, ”#2e7d32”, ”#1b5e20”, ”#b9f6ca”, ”#69f0ae”, ”#00e676”, ”#00c853”, ”#f1f8e9”, ”#dcedc8”, ”#c5e1a5”, ”#aed581”, ”#9ccc65”, ”#8bc34a”, ”#7cb342”, ”#689f38”, ”#558b2f”, ”#33691e”, ”#ccff90”, ”#b2ff59”, ”#76ff03”, ”#64dd17”, ”#f9fbe7”, ”#f0f4c3”, ”#e6ee9c”, ”#dce775”, ”#d4e157”, ”#cddc39”, ”#c0ca33”, ”#afb42b”, ”#9e9d24”, ”#827717”, ”#f4ff81”, ”#eeff41”, ”#c6ff00”, ”#aeea00”, ”#fffde7”, ”#fff9c4”, ”#fff59d”, ”#fff176”, ”#ffee58”, ”#ffeb3b”, ”#fdd835”, ”#fbc02d”, ”#f9a825”, ”#f57f17”, ”#ffff8d”, ”#ffff00”, ”#ffea00”, ”#ffd600”, ”#fff8e1”, ”#ffecb3”, ”#ffe082”, ”#ffd54f”, ”#ffca28”, ”#ffc107”, ”#ffb300”, ”#ffa000”, ”#ff8f00”, ”#ff6f00”, ”#ffe57f”, ”#ffd740”, ”#ffc400”, ”#ffab00”, ”#fff3e0”, ”#ffe0b2”, ”#ffcc80”, ”#ffb74d”, ”#ffa726”, ”#ff9800”, ”#fb8c00”, ”#f57c00”, ”#ef6c00”, ”#e65100”, ”#ffd180”, ”#ffab40”, ”#ff9100”, ”#ff6d00”, ”#fbe9e7”, ”#ffccbc”, ”#ffab91”, ”#ff8a65”, ”#ff7043”, ”#ff5722”, ”#f4511e”, ”#e64a19”, ”#d84315”, ”#bf360c”, ”#ff9e80”, ”#ff6e40”, ”#ff3d00”, ”#dd2c00”, ”#d7ccc8”, ”#bcaaa4”, ”#795548”, ”#d7ccc8”, ”#bcaaa4”, ”#8d6e63”, ”#eceff1”, ”#cfd8dc”, ”#b0bec5”, ”#90a4ae”, ”#78909c”, ”#607d8b”, ”#546e7a”, ”#cfd8dc”, ”#b0bec5”, ”#78909c” ]; this.colorTiles = (function() { var tiles = []; for (var i = 0; i < 46; i++) { tiles.push ({ color: randomColor(), colspan: randomSpan(), rowspan: randomSpan() }); } return tiles; })(); function randomColor() { return COLORS[Math.floor(Math.random() * COLORS.length)]; } function randomSpan() { var r = Math.random(); if (r < 0.8) { return 1; } else if (r < 0.9) { return 2; } else { return 3; } } } </script> </head> <body ng-app = “firstApplication”> <div id = “gridContainer” ng-controller = “gridController as ctrl” ng-cloak> <md-content layout-padding> <md-grid-list md-cols-gt-md = “12” md-cols-sm = “3” md-cols-md = “8” md-row-height-gt-md = “1:1” md-row-height = “4:3″ md-gutter-gt-md = “16px” md-gutter-gt-sm = “8px” md-gutter = “4px”> <md-grid-tile ng-repeat = “tile in ctrl.colorTiles” ng-style = “{ ”background”: tile.color }” md-colspan-gt-sm = “{{tile.colspan}}” md-rowspan-gt-sm = “{{tile.rowspan}}”> </md-grid-tile> </md-grid-list> </md-content> </div> </body> </html> Result Verify the result. Resize the screen to see the effect. Print Page Previous Next Advertisements ”;
Angular Material – Bottom Sheet ”; Previous Next The $mdBottomSheet, an Angular Service, is used to open a bottom sheet over the application and provides a simple promise API. S.N Method & Description 1 $mdBottomSheet.show(options); Show a bottom sheet with the specified options. S.N Parameter & Description 1 * options An options object, with the following properties − templateUrl – {string=} − The url of an html template file that will be used as the content of the bottom sheet. Restrictions: the template must have an outer md-bottom-sheet element. template – {string=} − Same as templateUrl, except this is an actual template string. scope – {object=} − The scope to link the template / controller to. If none is specified, it will create a new child scope. This scope will be destroyed when the bottom sheet is removed unless preserveScope is set to true. preserveScope – {boolean=} − It dictates whether to preserve the scope when the element is removed. By default, it is false. controller – {string=} − The controller to associate with this bottom sheet. locals – {string=} − An object containing key/value pairs. The keys will be used as names of values to inject into the controller. For example, locals: {three: 3} will inject three into the controller with the value of 3. clickOutsideToClose – {boolean=} − It dictates whether the user can click outside the bottom sheet to close it. By default, it is true. escapeToClose – {boolean=} − It dictates whether the user can press escape to close the bottom sheet. By default, it is true. resolve – {object=} − Similar to locals, except that it takes promises as values and the bottom sheet will not open until the promises resolve. controllerAs – {string=} − An alias to assign the controller to on the scope. parent – {element=} − The element to append the bottom sheet to. The parent may be a function, string, object, or null. Defaults to appending to the body of the root element (or the root element) of the application. e.g. angular.element(document.getElementById(”content”)) or “#content”. disableParentScroll – {boolean=} − Whether to disable scrolling while the bottom sheet is open. Default true. Sr.No Returns & Description 1 promise A promise that can be resolved with $mdBottomSheet.hide() or rejected with $mdBottomSheet.cancel(). Example The following example shows the use of the $mdBottomSheet service and also the use of bottom sheet. am_bottomsheet.htm Live Demo <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> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”bottomSheetController”, bottomSheetController); function bottomSheetController ($scope, $mdBottomSheet) { $scope.openBottomSheet = function() { $mdBottomSheet.show ({ template: ”<md-bottom-sheet>Learn <b>Angular Material</b> @ TutorialsPoint.com!</md-bottom-sheet>” }); }; } </script> </head> <body ng-app = “firstApplication”> <div ng-controller = “bottomSheetController as ctrl” layout = “column”> <md-content class = “md-padding”> <form ng-submit = “$event.preventDefault()”> <md-button class = “md-raised md-primary” ng-click = “openBottomSheet()”> Open Bottom Sheet! </md-button> </form> </md-content> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Angular Material – Fab Speed Dial ”; Previous Next The md-fab-speed-dial, an Angular directive, is used to show a series of popup elements or buttons for quick access to common actions. Attributes The following table lists out the parameters and description of the different attributes of md-fab-speed-dial. Sr.No Parameter & Description 1 * md-direction This determines the direction at which the speed dial is to appear relative to the trigger element. 2 md-open This helps programmatically control whether or not the speed-dial is visible. Example The following example shows the use of md-fab-speed-dial directive and also the uses of speed dial. am_speeddial.htm Live Demo <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”> <style> .fabSpeedDial .text-capitalize { text-transform: capitalize; } .fabSpeedDial .md-fab:hover, .fabSpeedDialdemoBasicUsage .md-fab.md-focused { background-color: #000 !important; } .fabSpeedDial p.note { font-size: 1.2rem; } .fabSpeedDial .lock-size { min-width: 300px; min-height: 300px; width: 300px; height: 300px; margin-left: auto; margin-right: auto; } </style> <script language = “javascript”> angular .module(”firstApplication”, [”ngMaterial”]) .controller(”speedDialController”, speedDialController); function speedDialController ($scope) { this.topDirections = [”left”, ”up”]; this.bottomDirections = [”down”, ”right”]; this.isOpen = false; this.availableModes = [”md-fling”, ”md-scale”]; this.selectedMode = ”md-fling”; this.availableDirections = [”up”, ”down”, ”left”, ”right”]; this.selectedDirection = ”up”; } </script> </head> <body ng-app = “firstApplication”> <div class = “fabSpeedDial” id = “speedDialContainer” ng-controller = “speedDialController as ctrl” layout = “row” ng-cloak> <md-content> <div class = “lock-size” layout = “row” layout-align = “center center”> <md-fab-speed-dial md-open = “ctrl.isOpen” md-direction = “{{ctrl.selectedDirection}}” ng-class = “ctrl.selectedMode”> <md-fab-trigger> <md-button aria-label = “menu” class = “md-fab md-warn”> <md-icon class = “material-icons”>menu</md-icon> </md-button> </md-fab-trigger> <md-fab-actions> <md-button aria-label = “Add” class = “md-fab md-raised md-mini md-accent”> <md-icon class = “material-icons” aria-label = “Add”> add</md-icon> </md-button> <md-button aria-label = “Insert Link” class = “md-fab md-raised md-mini md-accent”> <md-icon class = “material-icons” aria-label = “Insert Link”> insert_link</md-icon> </md-button> <md-button aria-label = “Edit” class = “md-fab md-raised md-mini md-accent”> <md-icon class = “material-icons” aria-label = “Edit”> mode_edit</md-icon> </md-button> </md-fab-actions> </md-fab-speed-dial> </div> <div layout = “row” layout-align = “space-around”> <div layout = “column” layout-align = “start center”> <b>Direction</b> <md-radio-group ng-model = “ctrl.selectedDirection”> <md-radio-button ng-repeat = “direction in ctrl.availableDirections” ng-value = “direction” class = “text-capitalize”> {{direction}} </md-radio-button> </md-radio-group> </div> <div layout = “column” layout-align = “start center”> <b>Open/Closed</b> <md-checkbox ng-model = “ctrl.isOpen”> Open </md-checkbox> </div> <div layout = “column” layout-align = “start center”> <b>Animation Modes</b> <md-radio-group ng-model = “ctrl.selectedMode”> <md-radio-button ng-repeat = “mode in ctrl.availableModes” ng-value = “mode”> {{mode}} </md-radio-button> </md-radio-group> </div> </div> </md-content> </div> </body> </html> Result Verify the result. Print Page Previous Next Advertisements ”;
Angular Material – Widgets
Angular Material – Widgets ”; Previous Next Angular Material provides a rich library of UI widgets. This allows users to have advanced interaction capability with the application. The following table lists down a few important Widgets with their description − Sr.No Widget & Description 1 Buttons The md-button, an Angular Directive, is a button directive having optional ink ripples (and are by default enabled). If href or ng-href attribute is provided, then this directive acts as an anchor element. 2 CheckBoxes The md-checkbox, an Angular Directive, is used as a checkbox control. 3 Content The md-content, an Angular Directive, is a container element and is used for scrollable content. The layout-padding attribute can be added to have padded content. 4 DatePicker The md-datepicker, an Angular Directive, is an input control to select a date. It also supports ngMessages for input validation. 5 Dialogs The md-dialog, an Angular Directive, is a container element and is used to display a dialog box. Its element md-dialog-content contains the content of the dialog and the md-dialog-actions is responsible for dialog actions. The mdDialog, an Angular Service, opens a dialog over the application to keep the users informed and help them make decisions. 6 Divider The md-divider, an Angular Directive, is a rule element and is used to display a thin lightweight rule to group and divide contents within lists and page layouts. 7 List The md-list, an Angular directive, is a container component that contains md-list-item elements as a children. The md-list-item directive is a container component for row items of md-list container. CSS classes md-2-line and md-3-line can be added to md-list-item to increase the height of row with 22px and 40px respectively. 8 Menu The md-menu, an Angular directive, is a component to display addition options within the context of action performed. The md-menu has two child elements. The first element is the trigger element and is used to open the menu. The second element is the md-menu-content to represent the content of the menu when the menu is opened. The md-menu-content usually carries the menu items as md-menu-item. 9 Menu Bar The md-menu-bar, is a container component to hold multiple menus. The menu bar helps to create an operating system provided menu effect. 10 Progress Bars The md-progress-circular and md-progress-linear are Angular progress directives, and are used to show the loading content message in application. 11 Radio Buttons The md-radio-group and md-radio-button Angular directives are used to show radio buttons in the applcation. The md-radio-group is the grouping container for md-radio-button elements. 12 Selects The md-select, an Angular directives is used to show Select box, bounded by ng-model. 13 Fab Toolbars The md-fab-toolbar, an Angular directive, is used to show a toolbar of elements or buttons for quick access to common actions. 14 Sliders The md-slider, an Angular directives is used to show a range component. It has two modes − normal − User can slide between wide range of values. Default. discrete − User can slide between selected values. To enable discrete mode use md-discrete and step attributes. 15 Tabs The md-tabs and md-tab Angular directives are used to show tabs in the applcation. md-tabs is the grouping container for md-tab elements. 16 Toolbars The md-toolbar, an Angular directives is used to show a toolbar which is normally an area above content to show the title and the relevant buttons. 17 Tooltips The Angular Material provides various special methods to show unobtrusive tooltips to the users. Angular Material provides ways to assign directions for them and md-tooltip directive is used to show tooltips. A tooltip activates whenever the user focuses, hovers over, or touches the parent component. 18 Chips The md-chips, an Angular Directive, is used as a special component called the Chip and can be used to represent small set of information for example, a contact, tags etc. Custom template can be used to render the content of a chip. This can be achieved by specifying an md-chip-template element having the custom content as a child of md-chips. 19 Contact Chips The md-contact-chips, an Angular Directive, is an input control built on md-chips and uses the md-autocomplete element. The contact chip component accepts a query expression which returns a list of possible contacts. A user can select one of these and add it to the list of availble chips. Print Page Previous Next Advertisements ”;
Angular Material – Overview
Angular Material – Overview ”; Previous Next Angular Material is a UI component library for Angular JS developers. Angular Material”s reusable UI components help in constructing attractive, consistent, and functional web pages and web applications while adhering to modern web design principles like browser portability, device independence, and graceful degradation. Following are a few salient features of Angular Material − In-built responsive designing. Standard CSS with minimal footprint. Includes new versions of common user interface controls such as buttons, check boxes, and text fields which are adapted to follow Material Design concepts. Includes enhanced and specialized features like cards, toolbar, speed dial, side nav, swipe, and so on. Cross-browser, and can be used to create reusable web components. Responsive Design Angular Material has in-built responsive designing so that the website created using Angular Material will redesign itself as per the device size. Angular Material classes are created in such a way that the website can fit any screen size. The websites created using Angular Material are fully compatible with PC, tablets, and mobile devices. Extensible Angular Material is by design very minimal and flat. It is designed considering the fact that it is much easier to add new CSS rules than to overwrite existing CSS rules. It supports shadows and bold colors. The colors and shades remain uniform across various platforms and devices. And most important of all, Angular Material is absolutely free to use. Print Page Previous Next Advertisements ”;