Angular Material vs. Material Design Lite

前端之家收集整理的这篇文章主要介绍了Angular Material vs. Material Design Lite前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

https://scotch.io/bar-talk/angular-material-vs-material-design-lite

@H_301_3@

@H_301_3@ In this article we’re going to explore the options that Google provides us when implementing Material Design in our websites & apps. While both Angular Material and Material Design Lite follow the Material Design specs,each library implements it in a different way.

@H_301_3@ It’s important to mention that both libraries have decent online documentation. They also have fast releases cycles and good support on github and related forums.

@H_301_3@ It’s also important to mention that both libraries,namespace their classes with themd-ormdl-prefix. Which is a good practice that helps preventing classes conflicts. Unlike the classes provided with bootstrap (btnfor example).

#Material Design

@H_301_3@ Material Design is a design language developed by Google. It aimed to make a consistent experience across all Google apps & platforms (YouTube,Android,Play,InBox,Gmail,etc.).

@H_301_3@ Google announced Material Design at the 2014 Google I/O conference.

@H_301_3@ Material Design emphasizes on responsive interactions,mainly through ripple effects.

@H_301_3@ Examine how the Material Response makes the element responsive to our touch input:

@H_301_3@ Source:https://www.google.com/design/spec/animation/responsive-interaction.html

@H_301_3@ Material Design also emphasizes on shadow effects to convey depth.

@H_301_3@ Watch the video again and notice how the element is being lifted on touch.

@H_301_3@ After the success that Material Design received with the Launch of Android 5,which was the first Material Design implementation,Google decided to release SDKs that allowed developers to integrate Material Design in their apps. Hence,Angular MaterialandMaterial Design Lite.

@H_301_3@ It’s not a competition between Angular Material and Material Design Lite. Google released those 2 SDKs so they can give us more choice depending on our use case.

@H_403_42@ #Getting started with Material Design Lite @H_301_3@ Since Material Design Lite does not have any dependency,it’s going to be easy to set up.

@H_301_3@ You can use your favorite tool to grab its source code.

@H_301_3@ bower:

bower install material-design-lite --save
@H_301_3@ npm:

npm  Or you can just browse togetmdl.ioand grab the source code.

@H_301_3@ Next,we need to create anindex.htmlfile and include MDL’s CSS file and JS files:

@H_403_65@<html>
    <body>
        <script src="https://storage.googleapis.com/code.getmdl.io/1.0.3/material.min.js"></script</body>
</html>
@H_301_3@ Now we can immediately use any of theMDL components.

@H_301_3@ Let’s say we want to add a raised button with ripples,we just need to add the following to the body:

<button class"mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect>
  Button
</button>
@H_301_3@ Although MDL has a Javascript library included,in most scenarios you won’t need to use Javascript at all. You only need to use the javascript library to register components when dynamically injecting templates.

componentHandler.upgradeAllRegistered();
@H_301_3@ Material Design Lite offers a variety of components such as buttons,cards,tabs,menus,sliders,text fields and more..

@H_301_3@ Here are some other elements using Material Design Lite:

@H_301_3@ Input

#Theming

#Getting started with Angular Material

@H_301_3@ Angular Material depends on angular,angular-animate and angular-aria. If you’re usingbowerornpmto manage your dependencies,then they will be automatically installed alongsideangular-material.

@H_301_3@ Let’s start by grabbing the source code for Angular Material.

install angular-material --save

@H_301_3@ Or if you’re not using any command line tool to download your dependencies,then continue reading and use the CDN links provided below.

@H_301_3@ Let’s setup theindex.htmlpage:

<html ng-app"app"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-animate.min.js"https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular-aria.min.js"https://ajax.googleapis.com/ajax/libs/angular_material/0.10.0/angular-material.min.js>

         
        "main.js Notice that we addedng-app="app"to our HTML tag because we need to bootstrap our angular app insidemain.js

(function(){
    "use strict";

    var app = angular.module('app', ['ngMaterial']);

})();
@H_301_3@ We addedngMaterialas a dependency to ourappmodule. And now we we can get started and add another raised button with ripples,but this time using Angular Material:

<md-button "md-raised>Hello There!</md-button