This repository was archived by the owner on Sep 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -92,8 +92,11 @@ function PanelDialogCtrl(mdPanelRef) {
92
92
93
93
94
94
PanelDialogCtrl . prototype . closeDialog = function ( ) {
95
- this . _mdPanelRef && this . _mdPanelRef . close ( ) . then ( function ( ) {
95
+ var panelRef = this . _mdPanelRef ;
96
+
97
+ panelRef && panelRef . close ( ) . then ( function ( ) {
96
98
angular . element ( document . querySelector ( '.demo-dialog-open-button' ) ) . focus ( ) ;
99
+ panelRef . destroy ( ) ;
97
100
} ) ;
98
101
} ;
99
102
Original file line number Diff line number Diff line change @@ -245,7 +245,9 @@ angular
245
245
* @ngdoc method
246
246
* @name MdPanelRef#close
247
247
* @description
248
- * Hides and detaches the panel.
248
+ * Hides and detaches the panel. Note that this will **not** destroy the panel. If you
249
+ * don't intend on using the panel again, call the {@link MdPanelRef#destroy destroy} method
250
+ * afterwards.
249
251
*
250
252
* @returns {!angular.$q.Promise } A promise that is resolved when the panel is
251
253
* closed.
@@ -963,6 +965,7 @@ MdPanelRef.prototype.detach = function() {
963
965
* Destroys the panel. The Panel cannot be opened again after this.
964
966
*/
965
967
MdPanelRef . prototype . destroy = function ( ) {
968
+ this . _config . scope . $destroy ( ) ;
966
969
this . _config . locals = null ;
967
970
} ;
968
971
Original file line number Diff line number Diff line change @@ -141,6 +141,16 @@ describe('$mdPanel', function() {
141
141
expect ( panelRef . _config . locals ) . toEqual ( null ) ;
142
142
} ) ;
143
143
144
+ it ( 'destroy should destroy the panel scope' , function ( ) {
145
+ openPanel ( DEFAULT_CONFIG ) ;
146
+
147
+ expect ( panelRef . _config . scope . $$destroyed ) . toBe ( false ) ;
148
+
149
+ panelRef . destroy ( ) ;
150
+
151
+ expect ( panelRef . _config . scope . $$destroyed ) . toBe ( true ) ;
152
+ } ) ;
153
+
144
154
describe ( 'promises logic:' , function ( ) {
145
155
var config ;
146
156
You can’t perform that action at this time.
0 commit comments