Table of Contents
Tutorial Angular Material
Resources
Steps to build app
Here are some generalized steps that may be used to conceptualize the application implementation process:
- Plan your layout and the components you want to use
- Use hard-coded HTML and mock content to make sure the components appear as desired
- Wire components to your application logic > Use the seamless integration possible with Angular directives and controllers > This integration assumes that you have unit tested your app logic
- The components (html, controller, services..) can be wired together with ui-router,…
- Add Responsive breakpoints
- Add Theming support
- Confirm ARIA compliance
- Write e2e Tests > It is important to validate your app logic with Angular Material UI components.
Step #1
@see tutorial_1.html
Here you modified the shell application [available in tutorial_0.html] to use Angular-Material.
Use Bower to install angular-material with bower install angular-material -D In the HTML, load the CSS and JS modules: Configure the app dependency on 'ngMaterial'
<head> <link href="./bower_components/angular-material/angular-material.css" rel="stylesheet" /> </head>
<body> <script src="./bower_components/angular/angular.js" type="text/javascript" ></script> <script src="./bower_components/angular-animate/angular-animate.js" type="text/javascript" ></script> <script src="./bower_components/angular-aria/angular-aria.js" type="text/javascript" ></script> <script src="./bower_components/angular-material/angular-material.js" type="text/javascript" ></script>
<script>
// Include the dependency upon ngMaterial - important !!
angular.module('starterApp', ['ngMaterial']);
</script>
</body>
Step #2:
@see tutorial_2.html
Here you used the wireframe planning and layout to identify the components and attributes needed.
Add the <md-toolbar>, <md-sidenav>, <md-content> containers > Note: that the md-sidenav is the container the Users master list view, and the md-content is the container for the User detail view. Add the layout and flex attributes to configure the container layouts and sizing aspects. Use md-locked-open to lock the sidenav open on the left Use the md-whiteframe-z2 to add a shadow the the sidenav
<body ng-app="starterApp" layout="column">
<!-- Container #1 (see wireframe) -->
<md-toolbar layout="row" >
<h1>Angular Material - Starter App</h1>
</md-toolbar>
<!-- Container #2 --> <div flex layout="row">
<!-- Container #3 -->
<md-sidenav md-is-locked-open="true" class="md-whiteframe-z2"></md-sidenav>
<!-- Container #4 -->
<md-content flex id="content"></md-content>
</div>
</body>
Step #3:
@see tutorial_3.html
Here you will use hard-coded elements to confirm rendering and layout of the container child elements and Angular Material components.
Add the <md-toolbar>, <md-sidenav>, <md-content> containers > Note: that the md-sidenav is the container for the master Users List view, and the md-content is the container for the detail User Detail view. Add the layout and flex attributes to configure the container layouts and sizing aspects. Use md-locked-open to lock the sidenav open on the left Use the md-whiteframe-z2 to add a shadow the the sidenav
<body ng-app="starterApp" layout="column">
<md-sidenav md-is-locked-open="true" class="md-whiteframe-z2">
<md-list>
<!-- List item #1 -->
<md-item >
<md-button>
<md-icon md-svg-src="./assets/svg/avatar-1.svg" class="avatar"></md-icon>
Lia Luogo
</md-button>
</md-item>
<!-- List item #2 -->
<md-item >
<md-button>
<md-icon md-svg-src="./assets/svg/avatar-4.svg" class="avatar"></md-icon>
Lawrence Ray
</md-button>
</md-item>
</md-list> </md-sidenav>
<md-content flex id="content">
<!-- User details sample -->
<md-icon md-svg-src="./assets/svg/avatar-1.svg" class="avatar"></md-icon>
<h2>Lia Luogo</h2>
<p>
I love cheese...
</p>
</md-content>
</body>
Step #4:
@see tutorial_4.html
Here you integrate your custom, application logic.
Define a Angular module for your custom code Define your data services, models, and controllers Load your custom code Register your Angular module for runtime DI
<script src=“./src/users/Users.js”
></script>
<
script src=“./src/users/UsersListController.js”
></script>
<
script src=“./src/users/UsersDataservice.js”
></script>
<script type=“text/javascript”
>