|
1 | 1 | export class DialogService {
|
2 |
| - constructor($mdDialog) { |
3 |
| - 'ngInject'; |
4 |
| - |
5 |
| - this.$mdDialog = $mdDialog |
6 |
| - } |
7 |
| - |
8 |
| - fromTemplate(template, options) { |
9 |
| - if (!template) { |
10 |
| - return false; |
11 |
| - } |
12 |
| - |
13 |
| - if (!options) { |
14 |
| - options = {}; |
15 |
| - } |
16 |
| - |
17 |
| - options.templateUrl = './views/dialogs/' + template + '/' + template + 'dialog.html' |
18 |
| - |
19 |
| - return this.$mdDialog.show(options); |
20 |
| - } |
21 |
| - |
22 |
| - hide() { |
23 |
| - return this.$mdDialog.hide(); |
24 |
| - } |
25 |
| - |
26 |
| - alert(title, content) { |
27 |
| - this.$mdDialog.show( |
28 |
| - this.$mdDialog.alert() |
29 |
| - .title(title) |
30 |
| - .content(content) |
31 |
| - .ok('Ok') |
32 |
| - ); |
33 |
| - } |
34 |
| - |
35 |
| - confirm(title, content) { |
36 |
| - return this.$mdDialog.show( |
37 |
| - this.$mdDialog.confirm() |
38 |
| - .title(title) |
39 |
| - .content(content) |
40 |
| - .ok('Ok') |
41 |
| - .cancel('Cancel') |
42 |
| - ); |
43 |
| - } |
| 2 | + constructor($mdDialog) { |
| 3 | + 'ngInject'; |
| 4 | + |
| 5 | + this.$mdDialog = $mdDialog |
| 6 | + } |
| 7 | + |
| 8 | + fromTemplate(template, options) { |
| 9 | + if (!template) { |
| 10 | + return false; |
| 11 | + } |
| 12 | + |
| 13 | + if (!options) { |
| 14 | + options = {}; |
| 15 | + } |
| 16 | + |
| 17 | + options.templateUrl = './views/dialogs/' + template + '/' + template + 'dialog.html' |
| 18 | + |
| 19 | + return this.$mdDialog.show(options); |
| 20 | + } |
| 21 | + |
| 22 | + hide() { |
| 23 | + return this.$mdDialog.hide(); |
| 24 | + } |
| 25 | + |
| 26 | + alert(title, content) { |
| 27 | + var alert = this.$mdDialog.alert() |
| 28 | + .title(title) |
| 29 | + .content(content) |
| 30 | + .ariaLabel(content) |
| 31 | + .ok('Ok'); |
| 32 | + |
| 33 | + this.$mdDialog.show(alert); |
| 34 | + } |
| 35 | + |
| 36 | + confirm(title, content) { |
| 37 | + var confirm = this.$mdDialog.confirm() |
| 38 | + .title(title) |
| 39 | + .content(content) |
| 40 | + .ariaLabel(content) |
| 41 | + .ok('Ok') |
| 42 | + .cancel('Cancel'); |
| 43 | + |
| 44 | + return this.$mdDialog.show(confirm); |
| 45 | + } |
| 46 | + |
| 47 | + prompt(title, content, placeholder) { |
| 48 | + var prompt = this.$mdDialog.prompt() |
| 49 | + .title(title) |
| 50 | + .textContent(content) |
| 51 | + .placeholder(placeholder) |
| 52 | + .ariaLabel(placeholder) |
| 53 | + .ok('Ok') |
| 54 | + .cancel('Cancel'); |
| 55 | + |
| 56 | + return this.$mdDialog.show(prompt); |
| 57 | + } |
44 | 58 | }
|
0 commit comments