File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 6262 // Now that we have access to the `scope` we can interpolate any expression given in the paginationId attribute and
6363 // potentially register a new ID if it evaluates to a different value than the rawId.
6464 var paginationId = $parse ( attrs . paginationId ) ( scope ) || attrs . paginationId || DEFAULT_ID ;
65+ // In case rawId != paginationId we deregister using rawId for the sake of general cleanliness
66+ // before registering using paginationId
67+ paginationService . deregisterInstance ( rawId ) ;
6568 paginationService . registerInstance ( paginationId ) ;
6669
6770 var repeatExpression ;
115118
116119 // Delegate to the link function returned by the new compilation of the ng-repeat
117120 compiled ( scope ) ;
121+
122+ // When the scope is destroyed, we make sure to remove the reference to it in paginationService
123+ // so that it can be properly garbage collected
124+ scope . $on ( '$destroy' , function destroyDirPagination ( ) {
125+ paginationService . deregisterInstance ( paginationId ) ;
126+ } ) ;
118127 } ;
119128 }
120129 } ;
351360 }
352361 } ;
353362
363+ this . deregisterInstance = function ( instanceId ) {
364+ delete instances [ instanceId ] ;
365+ } ;
366+
354367 this . isRegistered = function ( instanceId ) {
355368 return ( typeof instances [ instanceId ] !== 'undefined' ) ;
356369 } ;
410423 } ;
411424 } ;
412425 } ) ;
413- } ) ( ) ;
426+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments