@@ -124,6 +124,7 @@ function $StateRefDirective($state, $timeout) {
124
124
var type = getTypeInfo ( element ) ;
125
125
var active = uiSrefActive [ 1 ] || uiSrefActive [ 0 ] ;
126
126
var unlinkInfoFn = null ;
127
+ var hookFn ;
127
128
128
129
def . options = extend ( defaultOpts ( element , $state ) , attrs . uiSrefOpts ? scope . $eval ( attrs . uiSrefOpts ) : { } ) ;
129
130
@@ -143,7 +144,11 @@ function $StateRefDirective($state, $timeout) {
143
144
update ( ) ;
144
145
145
146
if ( ! type . clickable ) return ;
146
- element . bind ( "click" , clickHook ( element , $state , $timeout , type , function ( ) { return def ; } ) ) ;
147
+ hookFn = clickHook ( element , $state , $timeout , type , function ( ) { return def ; } ) ;
148
+ element . bind ( "click" , hookFn ) ;
149
+ scope . $on ( '$destroy' , function ( ) {
150
+ element . unbind ( "click" , hookFn ) ;
151
+ } ) ;
147
152
}
148
153
} ;
149
154
}
@@ -176,6 +181,7 @@ function $StateRefDynamicDirective($state, $timeout) {
176
181
var watch = '[' + group . map ( function ( val ) { return val || 'null' ; } ) . join ( ', ' ) + ']' ;
177
182
var def = { state : null , params : null , options : null , href : null } ;
178
183
var unlinkInfoFn = null ;
184
+ var hookFn ;
179
185
180
186
function runStateRefLink ( group ) {
181
187
def . state = group [ 0 ] ; def . params = group [ 1 ] ; def . options = group [ 2 ] ;
@@ -190,7 +196,11 @@ function $StateRefDynamicDirective($state, $timeout) {
190
196
runStateRefLink ( scope . $eval ( watch ) ) ;
191
197
192
198
if ( ! type . clickable ) return ;
193
- element . bind ( "click" , clickHook ( element , $state , $timeout , type , function ( ) { return def ; } ) ) ;
199
+ hookFn = clickHook ( element , $state , $timeout , type , function ( ) { return def ; } ) ;
200
+ element . bind ( "click" , hookFn ) ;
201
+ scope . $on ( '$destroy' , function ( ) {
202
+ element . unbind ( "click" , hookFn ) ;
203
+ } ) ;
194
204
}
195
205
} ;
196
206
}
0 commit comments