README
v1.0.0 - Angular Material Design -- Table Component
Usage
Add module:
angular.module('app', [
'ttmd.table'
]);
Include file:
require('angular-md-table/dist/tt-ui-md-table.min.css');
require('angular-md-table/dist/tt-ui-md-table.min.js');
Required dependencies
- Angular 1.5.2
- Angular Material 1.0.2
- Angular Translate Support
About Adding your translation
Inside libaray, use {{ value | translate }}
to get the translations.
If you do NOT need translation, you can just pass the string you want to display. If you do need translation, you can pass in the json path as when you use angular translation libaray.
For Example:
{
"title": {
"greeting": "Hello!"
}
}
<ttmd-table toolbar="{title: 'title.greeting'}"></ttmd-table>
Add missing translations:
In mobile view, there are two buttons needs your provide translations for other languages:
{
"util": {
"previous": "",
"next": ""
}
}
Default value for those are Previous
& Next
Features
Desktop view and mobile view
The default breakpoint is 'xs', able to pass breakpoint
bindings to the component
<ttmd-table items="vm.items" headers="vm.headers" breakpoint="sm"></ttmd-table>
Force Mobile View
If there is a case you only want to display mobile view, pass in force-mobile
:
<ttmd-table items="vm.items" headers="vm.headers" force-mobile="true"></ttmd-table>
Type
To re-render the data efficient, you can have type
:
<ttmd-table items="vm.accounts.dueDate" headers="vm.headers" type="dueDate"></ttmd-table>
The type
you pass in , will be the listType
inside js:
this.SomeService.fetchDataAccordingPagination(limit, offset, listType)
.then((res) => {
if(listType){
this.accounts[listType] = [
...res
];
}
})
Toolbar
To display the toolbar for the table, passing tooblar
attr. Which is an object contains title
and icon
:
Here icon
is Material font icon: string
<ttmd-table items="vm.items" headers="vm.headers" toolbar="{
title="Due Date"
icon="account_circle"
}"></ttmd-table>
Pagination
The desktop and mobile pagination will be handle differently. To enable pagination, need to pass in total-number
to tell how many pages in total. on-page-change
the function need to be called when fetch another page's data.
<ttmd-table items="vm.items" headers="vm.headers" total-number="vm.totalNumber" on-page-change="vm.fetchData(payload)"></ttmd-table>
Sort
Able to sort
data according to the attr, this should be an array, but currently, only work with the first element inside the array.
<ttmd-table items="vm.items" headers="vm.headers" sort=['dueDate']"></ttmd-table>
Exclude
If there is any attr inside the data you don't want to display on the interface, you can use exclude
:
<ttmd-table items="vm.items" headers="vm.headers" exclude="['id']"></ttmd-table>
Pipes
You can use Angular built-in filter such as date
& currency
by adding pipies
to format the field:
<ttmd-table items="vm.items" headers="vm.headers" pipes="vm.pipes"></ttmd-table>
this.pipes = {
currency: {
targets: ['amount', 'amountWithOutTax'],
foramt: '