300+ TOP ANGULAR MATERIAL Interview Questions and Answers

ANGULAR MATERIAL Interview Questions :-

1. What Is Angular Material?

Angular Material is a UI component library for Angular JS developers. Angular Material’s reusable UI components helps in constructing attractive, consistent, and functional web pages and web apps while adhering to modern web design principles like browser portability, device independence, and graceful degradation.

Some of its salient features are as follows:

  • 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.
    Free to use

2. How To Use Angular Material?

There are two ways to use Angular Material:

  1. Local Installation – You can download the Angular Material libraries using npm, jspm, or bower on your local machine and include it in your HTML code.
  2. CDN Based Version – You can include the angular-material.min.css and angular-material js files into your HTML code directly from the Content Delivery Network (CDN).

3. What Is Local Installation?

Use following npm commands to install Angular Material libraries

npm install angular-material

npm will download the files under node_modules > angular-material folder.

4. What Is Cdn Based Version?

You can include the angular-material.css and angular-material.js files into your HTML code directly from the Content Delivery Network (CDN). Google CDN provides content for the latest version.

5. What Is Angular Material Autocomplete?

md-autocomplete, an Angular Directive, is used as a special input control with an inbuilt drop-down to show all possible matches to a custom query. This control acts as a real-time suggestion box as soon as the user types in the input area. can be used to provide search results from local or remote data sources.md-autocomplete caches results when performing a query. After first call, it uses the cached results to eliminate unnecessary server requests or lookup logic and it can be disabled.

Attributes

  • * md-items: An expression in the format of item in items to iterate over matches for your search.
  • md-selected-item-change: An expression to be run each time a new item is selected.
  • md-search-text-change: An expression to be run each time the search text updates.
  • md-search-text: A model to bind the search query text to.
  • md-selected-item: A model to bind the selected item to.
  • md-item-text: An expression that will convert your object to a single string.
  • placeholder: Placeholder text that will be forwarded to the input.
  • md-no-cache: Disables the internal caching that happens in autocomplete.
  • ng-disabled: Determines whether or not to disable the input field.
  • md-min-length: Specifies the minimum length of text before autocomplete will make suggestions.

6. What Is Angular Material Bottom Sheet?

$mdBottomSheet, an Angular Service, is used to open a bottom sheet over the application and provides a simple promise API.

Methods: 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=}: whether to preserve the scope when the element is removed. Default 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} would inject three into the controller with the value of 3.

clickOutsideToClose – {boolean=}: Whether the user can click outside the bottom sheet to close it. Default true.

escapeToClose – {boolean=}: Whether the user can press escape to close the bottom sheet. Default true.

resolve – {object=}: Similar to locals, except 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.

7. What Is Angular Material Buttons?

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.

Attributes

  • md-no-ink: If set as true, disable ripple ink effects.
  • ng-disabled: Enable/Disable based on the expression.
  • md-ripple-size: Overrides the default ripple size logic. Options: full, partial, auto.
  • aria-label: Adds alternative text to button for accessibility, useful for icon buttons. If
  • no default text is found, a warning will be logged.

8. What Is 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.

  • <md-card-header>: Header for the card, holds avatar, text and squared image.
  • <md-card-avatar>: Card avatar.
  • md-user-avatar: Class for user image.
  • <md-icon>: Icon directive.
  • <md-card-header-text> : Contains elements for the card description.
  • md-title: Class for the card title.
  • md-subhead: Class for the card sub header.
  • <img>: Image for the card.
  • <md-card-title>: Card content title.
  • <md-card-title-text>: Card Title text container.

9. What Is Angular Material Checkboxes?

md-checkbox, an Angular Directive, is used as a checkbox control.

Attributes

  • * ng-model: Assignable angular expression to data-bind to.
  • name: Property name of the form under which the control is published.
  • ng-true-value: The value to which the expression should be set when selected.
  • ng-false-value: The value to which the expression should be set when not selected.
  • ng-change: Angular expression to be executed when input changes due to user
  • interaction with the input element.
  • md-no-ink: Use of attribute indicates use of ripple ink effects.
  • aria-label: Adds label to checkbox for accessibility. Defaults to checkbox’s text. If no
  • default text is found, a warning will be logged.

10. What Is Angular Material Chips?

md-chips, an Angular Directive, is used as a special component called Chip and can be used to represent small set of information for example, a contact, tags etc. Custom template can be used 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.

Attributes

  • * ng-model: Assignable angular expression to data-bind to.
  • * ng-model: A model to bind the list of items to.
  • * md-transform-chip: An expression of form myFunction($chip) that when called expects one of the following return values:
    ->an object representing the $chip input string.
    ->undefined to simply add the $chip input string, or.
    ->null to prevent the chip from being appended.
  • * md-require-match: If true, and the chips template contains an autocomplete, only allow selection of pre-defined chips (i.e. you cannot add new ones).
  • placeholder: Placeholder text that will be forwarded to the input.
  • secondary-placeholder: Placeholder text that will be forwarded to the input, displayed when there is at least on item in the list.
  • readonly: Disables list manipulation (deleting or adding list items), hiding the input and delete buttons.
  • md-on-add: An expression which will be called when a chip has been added.
  • md-on-remove: An expression which will be called when a chip has been removed.
  • md-on-select: An expression which will be called when a chip is selected.

11. What Is Angular Material Contact Chips?

md-contact-chips, an Angular Directive, is an input control built on md-chips and uses md-autocomplete element. The contact chip component accepts a query expression which returns a list of possible contacts. The user can select one of these and add it to the list of availble chips.

Attributes

  • * ng-model: A model to bind the list of items to.
  • * md-contacts: An expression expected to return contacts matching the search test, $query.
  • * md-contact-name: The field name of the contact object representing the contact’s name.
  • * md-contact-email: The field name of the contact object representing the contact’s email address.
  • * md-contact-image: The field name of the contact object representing the contact’s image.
  • placeholder: laceholder text that will be forwarded to the input.
  • secondary-placeholder: Placeholder text that will be forwarded to the input, displayed when there is at least on item in the list.
  • filter-selected: Whether to filter selected contacts from the list of suggestions shown in the autocomplete.

12. What Is Angular Material Content?

md-content, an Angular Directive, is a container element and is used for scrollable content. layout-padding attribute can be added have padded content.

13. What Is Angular Material Datepicker?

md-datepicker, an Angular Directive, is an input control to select a date and supports ngMessages for input validation.

Attributes

* ng-model: The component’s model. Expects a JavaScript Date object.
ng-change: Expression evaluated when the model value changes.
md-min-date: Expression representing a min date (inclusive).
md-max-date: Expression representing a max date (inclusive).
md-date-filter: Function expecting a date and returning a boolean whether it can be selected or not.
md-placeholder: The date input placeholder value.
ng-disabled: Whether the datepicker is disabled.
ng-required: Whether a value is required for the datepicker.

14. What Is Angular Material Dialogs?

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 md-dialog-actions is responsible for dialog actions.

mdDialog, an Angular Service, opens a dialog over the application to inform users about the information or require them to make decisions.

15. What Is Angular Material Divider?

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.

Attributes

md-inset: Add this attribute to activate the inset divider style.

ANGULAR MATERIAL Questions and Answers ::

16. What Is Angular Material Fab Speed Dial?

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

* md-direction: From which direction you would like the speed dial to appear relative to the trigger element.
md-open: Programmatically control whether or not the speed-dial is visible.

17. What Is Angular Material 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.

Attributes

* md-direction: From which direction you would like the toolbar items to appear relative to the trigger element. Supports left and right directions.
md-open: Programmatically control whether or not the toolbar is visible.

18. What Is Angular Material Grids?

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

* md-cols: Number of columns in the grid.
* 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.
md-gutter: The amount of space between tiles in CSS units (default 1px).
md-on-layout: Expression to evaluate after layout. Event object is available as $event, and contains performance information.

19. What Is Angular Material Icons?

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 Google Material Icons.

Attributes

* md-font-icon: String name of CSS icon associated with the font-face will be used to render the icon. Requires the fonts and the named CSS styles to be preloaded.
* md-font-set: 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.
* md-svg-src: String URL (or expression) used to load, cache, and display an external SVG.
* md-svg-icon: md-svg-icon 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.
aria-label: 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.
alt: 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.

20. What Is Angular Material Inputs?

The md-input-container an Angular directive, is a container component to contains any <input> or <textarea> element as a child. md-input-container also supports error handling using the standard ng-messages directives and animates the messages using ngEnter/ngLeave events or the ngShow/ngHide events.

Attributes

md-maxlength: The maximum number of characters allowed in this input. If this is specified, a character counter will be shown underneath the input. The purpose of md-maxlength is exactly to show the max length counter text. If you don’t want the counter text and only need “plain” validation, you can use the “simple” ng-maxlength or maxlength attributes.
aria-label: Aria-label is required when no label is present. A warning message will be logged in the console if not present.
placeholder: An alternative approach to using aria-label when the label is not PRESENT. The placeholder text is copied to the aria-label attribute.
md-no-autogrow: When present, textareas will not grow automatically.
md-detect-hidden: When present, textareas will be sized properly when they are revealed after being hidden. This is off by default for performance reasons because it guarantees a reflow every digest cycle.

21. What Is Angular Material Layouts?

Layout Directive

layout directive on a container element is used to specify the layout direction for its children. Following are the assignable values:

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,following layout APIs can be used to set the layout direction for devices with view widths.

layout: Sets default layout direction unless overridden by another breakpoint.
layout-xs: width < 600px
layout-gt-xs: width >= 600px
layout-sm: 600px <= width < 960px
layout-gt-sm: width >= 960px
layout-md: 960px <= width < 1280px
layout-gt-md: width >= 1280px
layout-lg: 1280px <= width < 1920px
layout-gt-lg: width >= 1920px
layout-xl: width >= 1920px

22. What Is Flex Directive?

flex directive on a container element is used to customize the size and position of elements. flex directive 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:

multiples of 5 – 5, 10, 15 … 100
33 – 33%
66 – 66%

23. What Is Angular Material List?

The md-list an Angular directive, is a container component to 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.

24. What Is Angular Material Menu?

The md-menu an Angular directive, is a component to display addition options within the context of action performed. md-menu have two child elements. First one is trigger element and is used to open the menu. Second element is md-menu-content to represent the content of the menu when menu is opened. md-menu-content usually carries menu items as md-menu-item.

Attributes

* md-position-mode: The position mode in the form of x, y. Default value is target,target. Right now the x axis also suppports target-right.
* md-offset: An offset to apply to the dropdown after positioning x, y. Default value is 0,0.
Ext JS Interview Questions
25. What Is Angular Material Menu Bar?

The md-menu-bar an Angular directive, is a container component to hold multiple menus. Menu bar helps to create a operating system provided menu effect.

26. What Is Angular Material Progress Bars?

The md-progress-circular and md-progress-linear are Angular progress directives, and are used to show loading content message in application.

Attributes – md-progress-circular

* md-mode: Select from one of two modes: ‘determinate’ and ‘indeterminate’. if the md-mode value is set as undefined or specified as not 1 of the two (2) valid modes, then .ng-hide will be auto-applied as a style to the component. if not configured, the md-mode=”indeterminate” will be auto injected as an attribute. If value=”” is also specified, however, then md-mode=”determinate” would be auto-injected instead.
value: In determinate mode, this number represents the percentage of the circular progress. Default: 0
md-diameter: This specifies the diamter of the circular progress. The value may be a percentage (eg ‘25%’) or a pixel-size value (eg ’48’). If this attribute is not present then a default value of ’48px’ is assumed.

27. What Is Angular Material Radio Buttons?

The md-radio-group and md-radio-button Angular directives are used to show radio buttons in the applcation. md-radio-group is the grouping container for md-radio-button elements.

Attributes – md-radio-group

* ng-model: Assignable angular expression to data-bind to.
md-no-ink: Use of attribute indicates flag to disable ink ripple effects.
Attributes – md-radio-button

* ng-model: Assignable angular expression to data-bind to.
* ngValue: Angular expression which sets the value to which the expression should be set when selected.
* value: The value to which the expression should be set when selected.
ngChange: Angular expression to be executed when input changes due to user interaction with the input element.
name: Property name of the form under which the control is published.
aria-label: Adds label to radio button for accessibility. Defaults to radio button’s text. If no text content is available, a warning will be logged.

28. What Is Angular Material Selects?

The md-select, an Angular directives is used to show Select box, bounded by ng-model.

Attributes – md-radio-group

* ng-model: The model!
multiple: Whether it’s multiple.
md-on-close: Expression to be evaluated when the select is closed.
placeholder: Placeholder hint text.
Optional label for accessibility. Only necessary if no placeholder or explicit label is present.
md-container-class: Class list to get applied to the .md-select-menu-container element (for custom styling).

29. What Is Angular Material Sidenav?

The md-sidenav, an Angular directives is used to show a container component which can be shown or hide programmatically. It slides out over the top of the main content region by default.

Attributes

md-is-open: A model bound to whether the sidenav is opened.
md-component-id: componentId to use with $mdSidenav service.
md-is-locked-open: When this expression evalutes to true, the sidenav ‘locks open’: it falls into the content’s flow instead of appearing over it. This overrides the is-open attribute. The $mdMedia() service is exposed to the is-locked-open attribute, which can be given a media query or one of the sm, gt-sm, md, gt-md, lg or gt-lg presets. Examples:

<md-sidenav md-is-locked-open=”shouldLockOpen”></md-sidenav>

<md-sidenav md-is-locked-open=”$mdMedia(‘min-width: 1000px’)”></md-sidenav>

<md-sidenav md-is-locked-open=”$mdMedia(‘sm’)”></md-sidenav> (locks open on small screens)

30. What Is Angular Material 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.
Attributes

md-discrete: Whether to enable discrete mode.
step: The distance between values the user is allowed to pick. Default 1.
min: The minimum value the user is allowed to pick. Default 0.
max: The maximum value the user is allowed to pick. Default 100.