### Installing Node.js Dependencies for AngularJS Material Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command installs all necessary Node.js packages and project dependencies defined in `package.json` for the AngularJS Material project. It's the first step required before running any build or test commands. ```Bash npm install ``` ```Bash npm i ``` -------------------------------- ### Installing Gulp v3 Globally Source: https://github.com/angular/material/blob/master/README.md This command installs Gulp version 3 globally on the system. Gulp is a JavaScript task runner used for automating development workflows, including building AngularJS Material. ```bash npm install -g gulp@3 ``` -------------------------------- ### Installing NPM Dependencies for AngularJS Material Source: https://github.com/angular/material/blob/master/README.md This command installs all required Node Package Manager (NPM) dependencies for the AngularJS Material project. It should be run from the project's root directory to set up the development environment. ```bash npm install ``` -------------------------------- ### Installing Latest Stable AngularJS Material via NPM Source: https://github.com/angular/material/blob/master/README.md This command installs the latest stable version of the AngularJS Material library from NPM into the project's node_modules directory. The --save flag adds it as a dependency in package.json. ```bash npm install angular-material --save ``` -------------------------------- ### Installing Latest Master Branch of AngularJS Material via NPM Source: https://github.com/angular/material/blob/master/README.md This command installs the most recent version of AngularJS Material directly from the master branch of its GitHub repository. It's used for accessing the very latest, potentially unstable, development version. ```bash npm install http://github.com/angular/bower-material#master --save ``` -------------------------------- ### Utilizing Additional Flex Values for Advanced Sizing Control Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-children.tmpl.html Presents a range of special `flex` values beyond percentages, offering more nuanced control over element growth and shrinkage. These include `none` (no grow/shrink), `nogrow` (shrinks but doesn't grow), `grow` (grows/shrinks, starts at 100%), `initial` (shrinks, starts at natural size), `auto` (grows/shrinks, starts at natural size), `noshrink` (grows but doesn't shrink), and `0` (grows/shrinks, starts at 0%). ```HTML flex="none" ``` ```HTML flex ``` ```HTML flex="nogrow" ``` ```HTML flex="grow" ``` ```HTML flex="initial" ``` ```HTML flex="auto" ``` ```HTML flex="noshrink" ``` ```HTML flex="0" ``` -------------------------------- ### Angular Material Typography and Button Usage Examples Source: https://github.com/angular/material/blob/master/docs/content/CSS/typography.md This comprehensive HTML snippet illustrates the practical application of various Angular Material typography classes (.md-body-1, .md-body-2, .md-caption) and the component, showcasing how to combine them for different text styles and interactive elements. ```HTML

Body copy with medium weight.

Button

Regular body copy with small text.

Caption ``` -------------------------------- ### Applying md-whiteframe Elevation 20 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 20. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="20" ``` -------------------------------- ### Applying md-whiteframe Elevation 21 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 21. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="21" ``` -------------------------------- ### Applying md-whiteframe Elevation 22 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 22. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="22" ``` -------------------------------- ### Applying md-whiteframe Elevation 24 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 24. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="24" ``` -------------------------------- ### Applying md-whiteframe Elevation 23 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 23. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="23" ``` -------------------------------- ### Applying md-whiteframe Elevation 17 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 17. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="17" ``` -------------------------------- ### Applying md-whiteframe Elevation 15 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 15. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="15" ``` -------------------------------- ### Implementing Responsive Flex Sizing with `flex` and `flex-gt-sm` Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-children.tmpl.html Shows how to apply different flex behaviors based on device screen size using responsive `flex` directives. This example sets an element to flex 33% on mobile devices and 66% on devices larger than small (`gt-sm`). This allows for adaptive layouts across various viewports. ```HTML flex="33" flex-gt-sm="66" ``` ```HTML flex="66" flex-gt-sm="33" ``` -------------------------------- ### Using Angular Material Component as Element (Nunjucks/Jinja2 Template) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/api/directive.template.html This snippet demonstrates how to use an Angular Material component as a custom HTML element. It dynamically generates the element tag and its attributes based on the component's name and parameters, suitable for direct component instantiation in templates. ```Nunjucks/Jinja2 Template <{$ doc.name | dashCase $} {%- for param in doc.params %} {$ directiveParam(param.alias or param.name, param.type, "=", "") $} {%- endfor %}> ... ``` -------------------------------- ### Implementing Standard HTML Checkbox with Angular Directives Source: https://github.com/angular/material/blob/master/src/components/checkbox/demoSyncing/index.html This snippet shows how to use a standard HTML element enhanced with Angular's ng-checked and ng-click directives. It provides an alternative to Material components for managing checkbox state and user interaction. ```HTML ``` -------------------------------- ### Applying md-whiteframe Elevation 2 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 2. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="2" ``` -------------------------------- ### Applying md-whiteframe Elevation 16 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 16. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="16" ``` -------------------------------- ### Applying md-whiteframe Elevation 19 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 19. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="19" ``` -------------------------------- ### Applying md-whiteframe Elevation 10 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 10. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="10" ``` -------------------------------- ### Applying md-whiteframe Elevation 5 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 5. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="5" ``` -------------------------------- ### Applying md-whiteframe Elevation 7 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 7. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="7" ``` -------------------------------- ### Applying md-whiteframe Elevation 11 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 11. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="11" ``` -------------------------------- ### Applying md-whiteframe Elevation 18 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 18. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="18" ``` -------------------------------- ### Implementing Dynamic Themes with md-theme-watch in AngularJS Material Source: https://github.com/angular/material/blob/master/docs/content/Theming/04_multiple_themes.md This HTML example demonstrates how to enable dynamic theme switching based on user interaction. The md-theme-watch directive ensures that the theme updates when the bound scope variable changes, allowing elements to switch themes dynamically. ```html
Default altTheme
I'm dynamic
``` -------------------------------- ### Standard ng-repeat List Example - HTML Source: https://github.com/angular/material/blob/master/docs/content/performance/internet-explorer.md This HTML snippet demonstrates a standard AngularJS `ng-repeat` implementation for displaying a list of people. While functional, it can lead to performance issues in Internet Explorer with large datasets due to extensive DOM manipulation and layout recalculations, especially when interacting with elements like `md-dialog`. ```html {{::person.name }}

{{::person.name }}

``` -------------------------------- ### Applying md-whiteframe Elevation 8 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 8. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="8" ``` -------------------------------- ### Applying md-whiteframe Elevation 13 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 13. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="13" ``` -------------------------------- ### Applying md-whiteframe Elevation 14 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 14. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="14" ``` -------------------------------- ### Displaying Start Date with Angular Date Pipe Source: https://github.com/angular/material/blob/master/src/components/datepicker/demoCalendar/index.html This snippet displays the `startDate` property from the controller (`ctrl`) using Angular's `date` pipe. The `shortDate` format argument ensures the date is presented in a localized short date format. ```Angular Template {{ctrl.startDate | date:shortDate}} ``` -------------------------------- ### Applying md-whiteframe Elevation 9 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 9. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="9" ``` -------------------------------- ### Applying md-whiteframe Elevation 3 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 3. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="3" ``` -------------------------------- ### Applying md-whiteframe Elevation 6 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 6. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="6" ``` -------------------------------- ### Applying md-whiteframe Elevation 1 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 1. This directive adds a subtle shadow effect, simulating a slightly raised surface. ```HTML md-whiteframe="1" ``` -------------------------------- ### Implementing Multi-Breakpoint Responsive Flex Sizing Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-children.tmpl.html Shows a comprehensive example of responsive flex sizing across multiple breakpoints: 100% on mobile, 50% on medium devices (`md`), and 25% on devices larger than medium (`gt-md`). This allows for fine-grained control over element sizing across a wide range of screen dimensions. ```HTML flex="100" flex-md="50" flex-gt-md="25" ``` -------------------------------- ### Applying md-whiteframe Elevation 4 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 4. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="4" ``` -------------------------------- ### Applying md-whiteframe Elevation 12 (HTML) Source: https://github.com/angular/material/blob/master/src/components/whiteframe/demoDirectiveAttributeUsage/index.html Demonstrates the use of the `md-whiteframe` directive in Angular Material to apply an elevation level of 12. This directive adds a shadow effect, simulating a raised surface. ```HTML md-whiteframe="12" ``` -------------------------------- ### Using Angular Material Directive as CSS Class (Nunjucks/Jinja2 Template) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/api/directive.template.html This snippet shows how to apply an Angular Material directive by adding a specific CSS class to an HTML element. It dynamically constructs the class attribute with directive-specific parameters, enabling styling and behavior modifications through CSS-based directive activation. ```Nunjucks/Jinja2 Template {% set sep = joiner(' ') %} <{$ doc.element $} class=" {%- for param in doc.params -%} {$ sep() $}{$ directiveParam(param.name, param.type, ': ', ';') $} {%- endfor %}"> ... ``` -------------------------------- ### Using Angular Material Directive as Attribute (Nunjucks/Jinja2 Template) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/api/directive.template.html This snippet illustrates the usage of an Angular Material directive as an HTML attribute. It applies the directive to an existing HTML element, dynamically adding attributes based on the directive's parameters. This is common for enhancing standard HTML elements with Angular Material functionality. ```Nunjucks/Jinja2 Template <{$ doc.element $} {%- for param in doc.params %} {$ directiveParam(param.name, param.type, "=", "") $} {%- endfor %}> ... ``` -------------------------------- ### Displaying Selected Items Array as JSON Source: https://github.com/angular/material/blob/master/src/components/checkbox/demoSyncing/index.html This snippet uses Angular's interpolation combined with the json pipe to render the selected array as a formatted JSON string. This is useful for debugging or visualizing the current state of selected items. ```Angular Template {{selected | json}} ``` -------------------------------- ### Optimized md-virtual-repeat List Example - HTML Source: https://github.com/angular/material/blob/master/docs/content/performance/internet-explorer.md This HTML snippet demonstrates the use of `md-virtual-repeat` to optimize large lists for performance, particularly in Internet Explorer. It only renders elements visible within the viewport, significantly reducing DOM size and improving layout calculation speeds. This approach is ideal for displaying millions of records efficiently, provided all list items have equal and static heights. ```html {{ person.name }}

{{ person.name }}

``` -------------------------------- ### Binding Phone Object Properties in Angular Template Source: https://github.com/angular/material/blob/master/src/components/list/demoBasicUsage/index.html Shows how to bind properties ('number', 'type') of a 'phone' object. These expressions are typically used to display details of a contact or similar structured data. ```Angular Template {{ phone.number }} ``` ```Angular Template {{ phone.type }} ``` -------------------------------- ### Binding Item Object Properties in Angular Template Source: https://github.com/angular/material/blob/master/src/components/list/demoBasicUsage/index.html Demonstrates binding individual properties ('who', 'what', 'notes') of an 'item' object. These expressions are typically used together to display structured data for a single entity, often in a multi-line list item. ```Angular Template {{ item.who }} ``` ```Angular Template {{ item.what }} ``` ```Angular Template {{ item.notes }} ``` -------------------------------- ### Building AngularJS Material Documentation Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command compiles the AngularJS Material documentation from source code into the `dist/docs` directory. The documentation is generated using `dgeni` and utilizes AngularJS Material's own layout, components, and themes. ```Bash npm run docs:build ``` -------------------------------- ### Illustrative JavaScript Code for Breaking Change in Commit Message Source: https://github.com/angular/material/blob/master/docs/guides/MERGE_REQUESTS.md This snippet provides an example of how JavaScript code changes, specifically a breaking change, are documented within a Git commit message. It shows both the old and new syntax for a constant, guiding users on necessary code updates. ```js $mdConstant.SOMETHING_ELSE ``` ```js $mdConstant.SOMETHING ``` -------------------------------- ### Displaying Item Value using Angular Interpolation Source: https://github.com/angular/material/blob/master/src/components/checkbox/demoSyncing/index.html This snippet utilizes Angular's interpolation syntax to display the value of the item variable. It typically serves as a label or descriptive text associated with a selectable item, often alongside a checkbox. ```Angular Template {{ item }} ``` -------------------------------- ### Building AngularJS Material Documentation and Demos Source: https://github.com/angular/material/blob/master/README.md This Gulp task builds the documentation and live demos for AngularJS Material, placing them in the /dist/docs directory. It's useful for local review of the library's features and API. ```bash gulp docs ``` -------------------------------- ### Interactively Rebasing Commits for Squashing (Shell) Source: https://github.com/angular/material/blob/master/docs/guides/MERGE_REQUESTS.md Describes how to start an interactive rebase session against `origin/master` to manipulate, merge, and rename commits, typically used to squash multiple commits into a single one before merging to maintain a clean Git log. ```sh git rebase --interactive origin/master ``` -------------------------------- ### Implementing Angular Material Checkbox for Item Selection Source: https://github.com/angular/material/blob/master/src/components/checkbox/demoSyncing/index.html This snippet demonstrates using the Angular Material component. It binds the checkbox's checked state to the exists(item, selected) function and its click event to toggle(item, selected), enabling selection management for items. ```HTML ``` -------------------------------- ### Setting and Removing Browser Color Theming at Runtime (AngularJS) Source: https://github.com/angular/material/blob/master/docs/content/Theming/06_browser_color.md This example shows how to dynamically set the browser header color at runtime using `$mdTheming.setBrowserColor` within an AngularJS controller. It also demonstrates how to properly remove the applied browser color when the controller's scope is destroyed, ensuring clean-up and preventing memory leaks. ```js myAppModule .controller('myCtrl', function($scope, $mdTheming) { var removeFunction = $mdTheming.setBrowserColor({ theme: 'myTheme', // Default is 'default' palette: 'accent', // Default is 'primary', any basic material palette and extended palettes are available hue: '200' // Default is '800' }); $scope.$on('$destroy', function () { removeFunction(); // COMPLETELY removes the browser color }) }) ``` -------------------------------- ### Running All Unit Tests for AngularJS Material Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command executes the complete suite of unit tests for the AngularJS Material project. It ensures comprehensive test coverage and validates the functionality of all components and services. ```Bash npm run test:full ``` -------------------------------- ### Applying Responsive Flex Order with `flex-order-gt-md` Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-children.tmpl.html Illustrates how to apply different `flex-order` values based on screen size using responsive directives like `flex-order-gt-md`. This example sets an element's order to '3' on devices larger than medium, overriding its default order for specific breakpoints. This enables adaptive element reordering for responsive designs. ```HTML flex-order-gt-md="3" ``` ```HTML flex-order-gt-md="1" ``` -------------------------------- ### Building and Watching AngularJS Material Documentation with Live Reload Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command builds the AngularJS Material library and its documentation, then watches for file changes to automatically rebuild and serve the documentation with live reload. It's used for local development and viewing docs at `http://localhost:8080`. ```Bash npm run docs:watch ``` -------------------------------- ### Applying Heading Styles in HTML Source: https://github.com/angular/material/blob/master/docs/content/CSS/typography.md This example shows how to apply AngularJS Material's typography classes to standard HTML heading tags (

,

,

). These classes (.md-display-3, .md-display-1, .md-headline) provide consistent visual styling for headings while preserving semantic structure. ```html

Headline

Headline

Headline

``` -------------------------------- ### Creating AngularJS Material Panels with Presets using $mdPanel Source: https://github.com/angular/material/blob/master/src/components/panel/demoPanelProvider/index.html This snippet illustrates how to create or open an `$mdPanel` instance by referencing a previously defined preset. By passing the preset name to `$mdPanel.create`, the panel inherits the pre-configured options, significantly reducing the amount of repetitive configuration code required for similar panels. ```JavaScript function MyController($mdPanel) { $mdPanel.create('myCustomPanelPreset', { // Optional: override or add more options specific to this instance attachTo: angular.element(document.body) }).then(function(panelRef) { panelRef.open(); }); } ``` -------------------------------- ### Displaying State Abbreviation with Angular Interpolation Source: https://github.com/angular/material/blob/master/src/components/input/demoInlineForm/index.html This snippet demonstrates Angular's interpolation syntax to display the 'abbrev' property of a 'state' object. It's typically used for one-way data binding to show dynamic content in templates, often within Angular Material form fields. ```HTML {{state.abbrev}} ``` -------------------------------- ### Displaying Autocomplete Result Item (Angular) Source: https://github.com/angular/material/blob/master/src/components/autocomplete/demoInsideDialog/dialog.tmpl.html This Angular template expression is used to display the `display` property of an `item` object, typically representing a selected or suggested value from an `md-autocomplete` component's data source. It renders the user-friendly text of the item. ```Angular {{item.display}} ``` -------------------------------- ### Debugging Specific AngularJS Material Component Demos Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This Gulp command is used to watch, build, and serve a specific component's demos for debugging purposes. It rebuilds the component source and demos on save, and the server provides live reload on port 8080, deploying a self-contained AngularJS application for the specified component. ```Bash gulp watch-demo -c textfield server ``` -------------------------------- ### Binding Todos Array Element Properties in Angular Template Source: https://github.com/angular/material/blob/master/src/components/list/demoBasicUsage/index.html Illustrates binding the 'who' property from elements of a 'todos' array using array indexing. This pattern is used for accessing specific items within a collection, such as a list of tasks or events. ```Angular Template {{ todos[0].who }} ``` ```Angular Template {{ todos[1].who }} ``` -------------------------------- ### Building Individual AngularJS Material Component Modules Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command compiles and deploys assets for each AngularJS Material component individually. Each component is treated as its own module, allowing for granular builds and distribution to `dist/modules/js/`. ```Bash npm run build:modules ``` -------------------------------- ### Example of Overlapping Responsive Flex Directives Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-children.tmpl.html Highlights an incorrect usage pattern where responsive flex directives overlap, specifically `flex-md` and `flex-gt-sm` both applying to 'medium' devices. This can lead to unpredictable layout behavior and should be avoided. It's crucial to ensure directives don't conflict for the same breakpoint. ```HTML flex="100" flex-md="50" flex-gt-sm="25" ``` -------------------------------- ### Defining Angular Material Slider Module and Directive - JavaScript Source: https://github.com/angular/material/blob/master/docs/guides/CODING.md This JavaScript snippet demonstrates the definition of the 'material.components.slider' module and the 'mdSlider' directive in AngularJS. It includes comprehensive ngdoc comments detailing the directive's purpose, its two modes ('normal' and 'discrete'), usage examples with embedded HTML, and a list of its parameters. It adheres to conventions like module naming and directive prefixing. ```js /** * @ngdoc module * @name material.components.slider */ angular.module('material.components.slider', [ 'material.core' ]) .directive('mdSlider', SliderDirective); /** * @ngdoc directive * @name mdSlider * @module material.components.slider * @restrict E * @description * The `` component allows the user to choose from a range of values. * * It has two modes: 'normal' mode, where the user slides between a wide range of values, and * 'discrete' mode, where the user slides between only a few select values. * * To enable discrete mode, add the `md-discrete` attribute to a slider, and use the `step` * attribute to change the distance between values the user is allowed to pick. * * @usage *

Normal Mode

* * * * * *

Discrete Mode

* * * * * * @param {boolean=} mdDiscrete Whether to enable discrete mode. * @param {number=} step The distance between values the user is allowed to pick. Default 1. * @param {number=} min The minimum value the user is allowed to pick. Default 0. * @param {number=} max The maximum value the user is allowed to pick. Default 100. */ function SliderDirective($mdTheming) { //... } ``` -------------------------------- ### Building AngularJS Material Library Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command compiles the entire AngularJS Material library, including JavaScript components, services, theming, and CSS/SCSS styles, deploying them to the `dist` directory. It generates `angular-material.js`, `angular-material.css|scss`, and layout files. ```Bash npm run build ``` -------------------------------- ### Running Fast Smoke Tests for AngularJS Material Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command executes a subset of tests, referred to as smoke tests, for the AngularJS Material project. It provides a quick way to verify basic functionality and ensure critical components are working as expected. ```Bash npm run test:fast ``` -------------------------------- ### Displaying Current Search Text (Angular) Source: https://github.com/angular/material/blob/master/src/components/autocomplete/demoInsideDialog/dialog.tmpl.html This Angular template expression accesses `ctrl.searchText`, which holds the current input value typed by the user into an `md-autocomplete` field. It's commonly used in 'no results found' messages to echo the user's query back to them. ```Angular {{ctrl.searchText}} ``` -------------------------------- ### Running ESLint for AngularJS Material Code Quality Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command executes ESLint across the AngularJS Material codebase to enforce coding standards and identify potential issues. It helps maintain code quality and consistency throughout the project. ```Bash npm run lint ``` -------------------------------- ### Building Minified Production Assets for AngularJS Material Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This command performs a production build of the AngularJS Material library, minifying JavaScript and CSS assets, stripping `console.log` statements, and autoprefixing CSS. It generates `angular-material.min.js`, `angular-material.min.css|scss`, and layout files for optimized deployment. ```Bash npm run build:prod ``` -------------------------------- ### Building Asset Cache for CodePen Demos - Shell Source: https://github.com/angular/material/blob/master/docs/guides/CODEPEN.md This command executes a shell script to generate an object literal containing SVG asset mappings. The output is then copied to the paste buffer, ready to be inserted into the `svg-assets-cache.js` file. This step is crucial for populating the asset cache used by CodePen demos. ```Shell ./scripts/build-asset-cache.sh | pbcopy ``` -------------------------------- ### Angular Material Component Source Project Structure - Text Source: https://github.com/angular/material/blob/master/docs/guides/CODING.md This snippet illustrates the standard directory structure for component modules within the Angular Material source directory. Each component has its own folder containing JavaScript, spec, and SCSS files, along with a demo sub-folder. ```text -- /src -- /components -- / -- .js -- .spec.js -- .scss -- -theme.scss -- /demo -- index.html -- style.css -- script.js ``` -------------------------------- ### Initializing Google Analytics for Page Tracking - JavaScript Source: https://github.com/angular/material/blob/master/docs/config/template/index.template.html This JavaScript snippet initializes Google Analytics and sends a pageview event. It sets up the 'ga' function globally, loads the analytics.js script asynchronously, and then uses 'ga' to create a tracker with a specific tracking ID and send an initial pageview. ```JavaScript (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-8594346-14', 'auto'); ga('send', 'pageview'); ``` -------------------------------- ### Generating Parameter Table (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro generates a formatted table for parameters, including headers for 'Parameter', 'Type', and 'Description'. It reuses the `paramList` macro to populate the table content. ```Nunjucks {% macro paramTable(params) %} {$ paramList(params) $} Parameter Type Description {% endmacro -%} ``` -------------------------------- ### Documenting 'this' Context in Nunjucks Template Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/methods.template.html This snippet demonstrates how the 'this' keyword, representing the method's execution context, is explicitly highlighted and documented within the generated output. It is used to provide clarity on what 'this' refers to for a particular method's implementation. ```JavaScript this ``` -------------------------------- ### Generating Return Value Table (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro generates a table for a function's return value, including headers for 'Returns' and 'Description'. It uses the `typeList` macro to display the return type and includes the function's description. ```Nunjucks {% macro returnTable(fn) -%} Returns Description {$ typeList(fn.typeList) $} {$ fn.description | marked $} {%- endmacro -%} ``` -------------------------------- ### Conditionally Rendering Return Table using Nunjucks Macros Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/returns.template.html This Nunjucks template snippet imports a `macros.html` file, aliasing it as `macros`. It then checks if the `doc.returns` property exists and is truthy. If so, it invokes the `returnTable` macro from the imported `macros` object, passing `doc.returns` as an argument to generate an HTML table of return values. This ensures that return documentation is only rendered when applicable. ```Nunjucks {% import \"./macros.html\" as macros %} {% if doc.returns -%}\n\n{$ macros.returnTable(doc.returns) $}\n\n{%- endif %} ``` -------------------------------- ### Generating Property Table (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html Similar to `paramTable`, this macro generates a formatted table specifically for properties, with headers for 'Property', 'Type', and 'Description'. It also leverages the `paramList` macro for content generation. ```Nunjucks {% macro propertyTable(params) %} {$ paramList(params) $} Property Type Description {% endmacro -%} ``` -------------------------------- ### Generating Parameter List (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro generates a detailed list of parameters, distinguishing between required and optional ones. It includes the parameter name, alias, type, description, and default value if applicable, formatted for documentation. ```Nunjucks {% macro paramList(params) %} {% for param in params %} {%if not param.type.optional %} **\* {$ param.name $}** {% if param.alias %}| {$ param.alias $}{% endif %} {$ typeList(param.typeList) $} {$ typeList(param.typeList) $} {$ param.description | marked $} {% if param.default %} _(default: {$ param.default $})_ {% endif %} {% endif %} {% endfor %} {% for param in params %} {%if param.type.optional %} {$ param.name $} {% if param.alias %}| {$ param.alias $}{% endif %} {$ typeList(param.typeList) $} {$ typeList(param.typeList) $} {$ param.description | marked $} {% if param.default %} _(default: {$ param.default $})_ {% endif %} {% endif %} {% endfor %} {% endmacro -%} ``` -------------------------------- ### Building AngularJS Material Distribution Files Source: https://github.com/angular/material/blob/master/README.md This Gulp task compiles the AngularJS Material JavaScript and CSS files, along with theme files, into the /dist directory. It's used to generate the production-ready library assets. ```bash gulp build ``` -------------------------------- ### Running Full AngularJS Material Test Suite Source: https://github.com/angular/material/blob/master/docs/guides/PULL_REQUESTS.md This command executes the complete test suite for the AngularJS Material project. It's essential to run this before submitting a pull request to ensure all changes pass existing tests and do not introduce regressions. ```shell npm run test:full ``` -------------------------------- ### Including AngularJS Material via GitCDN.xyz (HTML) Source: https://github.com/angular/material/blob/master/README.md This snippet shows how to integrate the latest development builds of AngularJS Material directly from the `bower-material/master` branch using GitCDN.xyz. It includes the necessary CSS and JavaScript files, along with AngularJS core dependencies, for developers needing the most current versions. ```html ``` -------------------------------- ### Defining AngularJS Material Panel Presets with $mdPanelProvider Source: https://github.com/angular/material/blob/master/src/components/panel/demoPanelProvider/index.html This snippet demonstrates how to define a reusable configuration preset for `$mdPanel` elements using `$mdPanelProvider.definePreset` within an AngularJS `.config` block. It allows developers to store common panel options, excluding those dependent on user interaction, positioning, or animation, for later reuse when creating panels. ```JavaScript angular.module('myApp').config(function($mdPanelProvider) { $mdPanelProvider.definePreset('myCustomPanelPreset', { template: '
Hello from Preset!
', controller: 'MyPanelController', has Backdrop: true }); }); ``` -------------------------------- ### Displaying End Date with Angular Date Pipe Source: https://github.com/angular/material/blob/master/src/components/datepicker/demoCalendar/index.html This snippet displays the `endDate` property from the controller (`ctrl`) using Angular's `date` pipe. Similar to the start date, the `shortDate` format argument is applied for consistent formatting. ```Angular Template {{ctrl.endDate | date:shortDate}} ``` -------------------------------- ### Combining Layout Margin, Padding, and Fill (HTML) Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-options.tmpl.html Demonstrates the simultaneous application of `layout-margin`, `layout-padding`, and `layout-fill` directives on a single element. This allows for comprehensive control over spacing and sizing within a layout. ```HTML
...
``` -------------------------------- ### Generating Function Positional Syntax (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro generates a standard function signature with positional parameters. It lists each parameter by name, enclosing optional parameters in square brackets. ```Nunjucks {% macro functionSyntax(fn) %} {%- set sep = joiner(', ') -%} {$ fn.name $}({%- for param in fn.params %}{$ sep() $} {%- if param.type.optional %}\[{% endif -%} {$ param.name $} {%- if param.type.optional %}\]{% endif -%} {% endfor %}); {% endmacro -%} ``` -------------------------------- ### Applying Responsive Show/Hide Directives (HTML) Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-options.tmpl.html Demonstrates the use of responsive `show` and `hide` directives in Angular Material to conditionally display or conceal elements based on device screen size breakpoints. These directives are media query-aware alternatives to `ng-show` and `ng-hide`. ```HTML
Only show on gt-sm devices.
``` ```HTML
Shown on small and medium.
``` ```HTML
Shown on small and medium size devices.
``` ```HTML
Shown on medium size devices only.
``` ```HTML
Shown on devices larger than 1200px wide only.
``` -------------------------------- ### Loading Roboto Font in HTML Source: https://github.com/angular/material/blob/master/docs/content/CSS/typography.md This snippet demonstrates how to load the Roboto font from a CDN using a tag in HTML. AngularJS Material uses Roboto, but developers are responsible for loading it. This ensures the correct font is available for typography. ```html ``` -------------------------------- ### Angular Material Component Distribution Structure - Library - Text Source: https://github.com/angular/material/blob/master/docs/guides/CODING.md This snippet describes the distribution of all component modules as a single library. The compiled Angular Material JavaScript and CSS files are deployed directly to the '/dist' directory. ```text -- /dist -- angular.material.js -- angular.material.css ``` -------------------------------- ### Running AngularJS Material in Development Watch Mode Source: https://github.com/angular/material/blob/master/README.md This NPM script initiates a watch mode for AngularJS Material development. It continuously rebuilds the source, documentation, and demos whenever changes are detected, facilitating rapid development and testing. ```bash npm run docs:watch ``` -------------------------------- ### Generating Function Option Syntax (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro generates a function signature where parameters are passed as properties of an options object. It formats each parameter with its name and type, indicating optional parameters with square brackets. ```Nunjucks {% macro functionOptionSyntax(fn) %} {%- set sep = joiner(', ') -%} `{$ fn.name $}({` {%- for param in fn.params %} `{%- if param.type.optional %}[{% endif -%} {$ param.name $}: {$ param.type.name $} {%- if param.type.optional %}]{% endif -%},` {% endfor %} `});` {% endmacro -%} ``` -------------------------------- ### Displaying Formatted Pizza Order Details - Angular Source: https://github.com/angular/material/blob/master/src/components/select/demoOptionGroups/index.html This snippet illustrates more advanced data binding in an Angular template, including method calls. It displays the 'size' in lowercase and uses a 'printSelectedToppings()' function to format and show the chosen toppings, providing a summary of the order. ```Angular {{size.toLowerCase()}} {{printSelectedToppings()}} ``` -------------------------------- ### Formatting Directive Parameter (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro formats a single directive parameter, enclosing it in square brackets (`[]`) if it is optional. It combines the parameter name, join character, and description. ```Nunjucks {% macro directiveParam(name, type, join, sep) %} {%- if type.optional %}\[{% endif -%} {$ name | dashCase $}{$ join $}{$ type.description $}{$ sep $} {%- if type.optional %}\]{% endif -%} {% endmacro -%} ``` -------------------------------- ### Implementing an Angular Material Dialog with $mdDialog Source: https://github.com/angular/material/blob/master/src/components/fabSpeedDial/demoMoreOptions/index.html This HTML snippet defines an Angular Material dialog (`md-dialog`) structure. It includes a toolbar, content area displaying dynamic data (`{{dialog.item.name}}`), and action buttons for closing or submitting the dialog, typically opened via the `$mdDialog` service. This structure is used to present interactive pop-up windows to the user. ```HTML
Cool Dialog!
Hello user! you clicked {{dialog.item.name}}. Close Greeting Submit
``` -------------------------------- ### Using Angular Material Layout Directives in HTML Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-introduction.tmpl.html This HTML snippet demonstrates the use of Angular Material's 'layout' and 'flex' directives. These attributes are used to define the layout and sizing of elements within a container, providing a declarative way to structure UI components before runtime transformation. ```HTML
First item in row
Second item in row
First item in column
Second item in column
``` -------------------------------- ### Configuring Browser Color Theming with $mdThemingProvider (AngularJS) Source: https://github.com/angular/material/blob/master/docs/content/Theming/06_browser_color.md This snippet demonstrates how to enable and configure browser header color theming during the AngularJS application's configuration phase. It uses `$mdThemingProvider.enableBrowserColor` to set the theme, palette, and hue, allowing for a consistent Material Design experience on mobile browsers. ```js myAppModule .config(function($mdThemingProvider) { // Enable browser color $mdThemingProvider.enableBrowserColor({ theme: 'myTheme', // Default is 'default' palette: 'accent', // Default is 'primary', any basic material palette and extended palettes are available hue: '200' // Default is '800' }); }); ``` -------------------------------- ### Disabling Ink Ripple Effects in AngularJS Material for IE Source: https://github.com/angular/material/blob/master/docs/content/performance/internet-explorer.md This example shows how to turn off the material ink ripple animation effects in an AngularJS Material application, specifically targeting Internet Explorer. It uses `$mdInkRippleProvider.disableInkRipple()` within the module's config block, conditional on detecting IE. ```js var isIE = window.document.documentMode; angular .module('myApp', ['ngMaterial']) .config( function($mdInkRippleProvider) { if (isIE) { $mdInkRippleProvider.disableInkRipple(); } }); ``` -------------------------------- ### Angular Material Component Distribution Structure - Modules - Text Source: https://github.com/angular/material/blob/master/docs/guides/CODING.md This snippet shows the distribution structure for individual compiled component modules. After compilation, each component is placed in its respective folder under the '/dist/modules/js' directory. ```text -- /dist -- /modules -- /js -- /core -- / ``` -------------------------------- ### Exporting AngularJS Material Theming CSS to Clipboard - JavaScript Source: https://github.com/angular/material/blob/master/docs/content/performance/internet-explorer.md This JavaScript snippet, intended for execution in Chrome DevTools, copies the dynamically generated AngularJS Material theming CSS to the clipboard. It identifies style elements with the 'md-theme-style' attribute and concatenates their content, enabling the theme to be saved to an external static file for improved Internet Explorer performance. ```js copy([].slice.call(document.styleSheets) .map(e => e.ownerNode) .filter(e => e.hasAttribute('md-theme-style')) .map(e => e.textContent) .join('\n'); ); ``` -------------------------------- ### Generating a Predefined Theme at Runtime in AngularJS Material Source: https://github.com/angular/material/blob/master/docs/content/Theming/04_multiple_themes.md This JavaScript code shows how to explicitly generate a theme at runtime using $mdTheming.generateTheme(). This is necessary when generateThemesOnDemand is enabled, ensuring the theme's CSS is created before it's used in the application. ```js $mdTheming.generateTheme('altTheme'); ``` -------------------------------- ### Displaying Initial Model State in AngularJS Template Source: https://github.com/angular/material/blob/master/src/components/select/demoTrackBy/index.html This snippet demonstrates how to display the initial state of `ctrl.selectedItem` using AngularJS one-time binding (`::`). The `| json` filter formats the object as a JSON string. This binding updates only once upon initialization. ```AngularJS Template {{ ::ctrl.selectedItem | json }} ``` -------------------------------- ### Generating Type List (Nunjucks) Source: https://github.com/angular/material/blob/master/docs/config/template/ngdoc/lib/macros.html This macro formats a list of type names, joining them with a pipe (`|`) and escaping each name. It is typically used to display the types of parameters or return values in documentation. ```Nunjucks {% macro typeList(types) -%} {%- set sep = joiner('|') %} {% for typeName in types %}`{$ typeName | escape $}`{% endfor %} {%- endmacro -%} ``` -------------------------------- ### Creating a New Git Branch for a Fix Source: https://github.com/angular/material/blob/master/docs/guides/PULL_REQUESTS.md This command creates a new local Git branch named 'wip/my-fix-branch' based on the 'master' branch. It's a crucial first step for isolating changes and preparing for a pull request. ```shell git checkout -b wip/my-fix-branch master ``` -------------------------------- ### Defining AngularJS Material Slider Component Module Source: https://github.com/angular/material/blob/master/docs/guides/BUILD.md This JavaScript snippet illustrates the module definition for the AngularJS Material Slider component. It registers `material.components.slider` as an AngularJS module, declaring its dependency on `material.core`, which is a minimum requirement for all components. ```JavaScript /** * @ngdoc module * @name material.components.slider */ angular.module('material.components.slider', [ 'material.core' ]); ``` -------------------------------- ### Using Flex and Layout Wrap (HTML) Source: https://github.com/angular/material/blob/master/docs/app/partials/layout-options.tmpl.html Illustrates the `layout-wrap` directive combined with `flex` attributes. `layout-wrap` enables `flex` children to wrap to the next line if their combined width exceeds 100%, while `flex` defines the proportional width of each child. ```HTML
``` -------------------------------- ### Committing Changes with Automatic Add/Remove Source: https://github.com/angular/material/blob/master/docs/guides/PULL_REQUESTS.md This command commits all modified, deleted, and newly added files to the local repository. The '-a' option automatically stages all tracked files, simplifying the commit process. ```shell git commit -a ``` -------------------------------- ### Pushing Local Branch to GitHub Remote Source: https://github.com/angular/material/blob/master/docs/guides/PULL_REQUESTS.md This command pushes the local 'wip/my-fix-branch' to the 'origin' remote repository on GitHub. This makes the branch available online and allows for the creation of a pull request. ```shell git push origin wip/my-fix-branch ```