File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 6868 // Now that we have access to the `scope` we can interpolate any expression given in the paginationId attribute and
6969 // potentially register a new ID if it evaluates to a different value than the rawId.
7070 var paginationId = $parse ( attrs . paginationId ) ( scope ) || attrs . paginationId || DEFAULT_ID ;
71+ // In case rawId != paginationId we deregister using rawId for the sake of general cleanliness
72+ // before registering using paginationId
73+ paginationService . deregisterInstance ( rawId ) ;
7174 paginationService . registerInstance ( paginationId ) ;
7275
7376 var repeatExpression = getRepeatExpression ( expression , paginationId ) ;
102105
103106 // Delegate to the link function returned by the new compilation of the ng-repeat
104107 compiled ( scope ) ;
108+
109+ // When the scope is destroyed, we make sure to remove the reference to it in paginationService
110+ // so that it can be properly garbage collected
111+ scope . $on ( '$destroy' , function destroyDirPagination ( ) {
112+ paginationService . deregisterInstance ( paginationId ) ;
113+ } ) ;
105114 } ;
106115 }
107116
520529 }
521530 } ;
522531
532+ this . deregisterInstance = function ( instanceId ) {
533+ delete instances [ instanceId ] ;
534+ } ;
535+
523536 this . isRegistered = function ( instanceId ) {
524537 return ( typeof instances [ instanceId ] !== 'undefined' ) ;
525538 } ;
You can’t perform that action at this time.
0 commit comments