|
| 1 | +// Include app dependency on ngMaterial |
| 2 | +var app = angular.module( 'YourApp', [ 'ngMaterial' ] ); |
| 3 | +app.controller("YourController", ['$scope', '$mdDialog', function($scope, $mdDialog) { |
| 4 | + |
| 5 | + $scope.openDialog = function($event) { |
| 6 | + $mdDialog.show({ |
| 7 | + targetEvent: $event, |
| 8 | + template: |
| 9 | + '<md-dialog>' + |
| 10 | + ' <md-content>Hello {{ userName }}!</md-content>' + |
| 11 | + ' <div class="md-actions">' + |
| 12 | + ' <md-button ng-click="closeDialog()">' + |
| 13 | + ' Close' + |
| 14 | + ' </md-button>' + |
| 15 | + ' </div>' + |
| 16 | + '</md-dialog>', |
| 17 | + controller: 'DialogController', |
| 18 | + onComplete: afterShowAnimation, |
| 19 | + locals: { name: 'Bobby' } |
| 20 | + }); |
| 21 | + // When the 'enter' animation finishes... |
| 22 | + function afterShowAnimation(scope, element, options) { |
| 23 | + // post-show code here: DOM element focus, etc. |
| 24 | + } |
| 25 | + }; |
| 26 | + |
| 27 | + $scope.chunks = [ |
| 28 | + { |
| 29 | + title: "Something", |
| 30 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 31 | + expanded: false, |
| 32 | + content: { |
| 33 | + type: "QUOTE", |
| 34 | + quote: "And he saw that it was good" |
| 35 | + } |
| 36 | + }, |
| 37 | + { |
| 38 | + title: "Another Something", |
| 39 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 40 | + expanded: false, |
| 41 | + content: { |
| 42 | + type: "QUOTE", |
| 43 | + quote: "And he saw that it was good" |
| 44 | + } |
| 45 | + }, |
| 46 | + { |
| 47 | + title: "And even another Something", |
| 48 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 49 | + expanded: false, |
| 50 | + content: { |
| 51 | + type: "QUOTE", |
| 52 | + quote: "And he saw that it was good" |
| 53 | + } |
| 54 | + }, |
| 55 | + { |
| 56 | + title: "And even another Something", |
| 57 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 58 | + expanded: false, |
| 59 | + content: { |
| 60 | + type: "QUOTE", |
| 61 | + quote: "And he saw that it was good" |
| 62 | + } |
| 63 | + }, |
| 64 | + { |
| 65 | + title: "And even another Something", |
| 66 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 67 | + expanded: false, |
| 68 | + content: { |
| 69 | + type: "QUOTE", |
| 70 | + quote: "And he saw that it was good" |
| 71 | + } |
| 72 | + }, |
| 73 | + { |
| 74 | + title: "And even another Something", |
| 75 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 76 | + expanded: false, |
| 77 | + content: { |
| 78 | + type: "QUOTE", |
| 79 | + quote: "And he saw that it was good" |
| 80 | + } |
| 81 | + }, |
| 82 | + { |
| 83 | + title: "And even another Something", |
| 84 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 85 | + expanded: false, |
| 86 | + content: { |
| 87 | + type: "QUOTE", |
| 88 | + quote: "And he saw that it was good" |
| 89 | + } |
| 90 | + }, |
| 91 | + { |
| 92 | + title: "And even another Something", |
| 93 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 94 | + expanded: false, |
| 95 | + content: { |
| 96 | + type: "QUOTE", |
| 97 | + quote: "And he saw that it was good" |
| 98 | + } |
| 99 | + }, |
| 100 | + { |
| 101 | + title: "And even another Something", |
| 102 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 103 | + expanded: false, |
| 104 | + content: { |
| 105 | + type: "QUOTE", |
| 106 | + quote: "And he saw that it was good" |
| 107 | + } |
| 108 | + }, |
| 109 | + { |
| 110 | + title: "And even another Something", |
| 111 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 112 | + expanded: false, |
| 113 | + content: { |
| 114 | + type: "QUOTE", |
| 115 | + quote: "And he saw that it was good" |
| 116 | + } |
| 117 | + }, |
| 118 | + { |
| 119 | + title: "And even another Something", |
| 120 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 121 | + expanded: false, |
| 122 | + content: { |
| 123 | + type: "QUOTE", |
| 124 | + quote: "And he saw that it was good" |
| 125 | + } |
| 126 | + }, |
| 127 | + { |
| 128 | + title: "And even another Something", |
| 129 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 130 | + expanded: false, |
| 131 | + content: { |
| 132 | + type: "QUOTE", |
| 133 | + quote: "And he saw that it was good" |
| 134 | + } |
| 135 | + }, |
| 136 | + { |
| 137 | + title: "And even another Something", |
| 138 | + description: "Lorem Ipsum Dolor Set Shalalala", |
| 139 | + expanded: false, |
| 140 | + content: { |
| 141 | + type: "QUOTE", |
| 142 | + quote: "And he saw that it was good" |
| 143 | + } |
| 144 | + } |
| 145 | + ]; |
| 146 | + |
| 147 | + $scope.items = [ |
| 148 | + { name: 'Share', icon: 'share' }, |
| 149 | + { name: 'Upload', icon: 'upload' }, |
| 150 | + { name: 'Copy', icon: 'copy' }, |
| 151 | + { name: 'Print this page', icon: 'print' }, |
| 152 | + ]; |
| 153 | + |
| 154 | + $scope.listItemClick = function($index) { |
| 155 | + var clickedItem = $scope.items[$index]; |
| 156 | + $mdBottomSheet.hide(clickedItem); |
| 157 | + }; |
| 158 | +}]); |
| 159 | + |
| 160 | +app.controller('DialogController', function($scope, $mdDialog, name) { |
| 161 | + $scope.userName = name; |
| 162 | + $scope.closeDialog = function() { |
| 163 | + $mdDialog.hide(); |
| 164 | + }; |
| 165 | +}); |
0 commit comments