Skip to content

Commit 91cede2

Browse files
committed
- Added notes on mdcDateTimeDialog service to README.md
1 parent a18712f commit 91cede2

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ npm i ng-material-datetimepicker
4747

4848
## Live Example
4949

50-
Click [here](https://beenote.github.io/angular-material-datetimepicker/) to see live examples.
50+
Click [here](https://logbon72.github.io/angular-material-datetimepicker/) to see live examples.
5151

5252
## Usage
5353

@@ -95,6 +95,51 @@ The directive accepts several attributes which are described below:
9595
| **ok-text** | String | Text for the OK button (default: OK) |
9696
| **week-start** | Number | First day of the week (default: 0 => Sunday) |
9797

98-
### Important Note on Using Locales
98+
### Date/Time Dialog Service
99+
100+
You can also use the Date Time picker as a service, using the `mdcDateTimeDialog` service. The dialog returns a promise which is resolved with the selected date-time value and rejected on cancellation.
101+
102+
Example usage:
103+
104+
```javascript
105+
someModule.controller('DemoCtrl', function ($scope, mdcDateTimeDialog) {
106+
107+
$scope.displayDialog = function () {
108+
mdcDateTimeDialog.show({
109+
maxDate: $scope.maxDate,
110+
time: false
111+
})
112+
.then(function (date) {
113+
$scope.selectedDateTime = date;
114+
console.log('New Date / Time selected:', date);
115+
}, function() {
116+
console.log('Selection canceled');
117+
});
118+
};
119+
})
120+
```
121+
122+
The `mdcDateTimeDialog.show` accepts the same options as the directive.
123+
124+
```javascript
125+
{
126+
date: {boolean} =true,
127+
time: {boolean} =true,
128+
format: {string} ='YYYY-MM-DD',
129+
minDate: {strign} =null,
130+
maxDate: {string} =null,
131+
currentDate: {string} =null,
132+
lang: {string} =mdcDatetimePickerDefaultLocale.locale,
133+
weekStart: {int} =0,
134+
shortTime: {boolean} =false,
135+
cancelText: {string} ='Cancel',
136+
todayText: {string} ='Today',
137+
okText: {string} ='OK',
138+
amText: {string} ='AM',
139+
pmText: {string} ='PM'
140+
}
141+
```
142+
143+
## Important Note on Using Locales
99144

100145
Please see this [issue](https://github.com/logbon72/angular-material-datetimepicker/issues/51). To use a locale with your date time picker dialog, you'll have to include the moment.js locale file.

0 commit comments

Comments
 (0)