Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0fc9ec2

Browse files
committed
fix(upgrade): clean up scope when element is destroyed
Closes angular#8102
1 parent d094a85 commit 0fc9ec2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

modules/angular2/src/upgrade/angular_js.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface IRootScopeService {
2222
$new(isolate?: boolean): IScope;
2323
$id: string;
2424
$watch(expr: any, fn?: (a1?: any, a2?: any) => void): Function;
25+
$destroy(): any;
2526
$apply(): any;
2627
$apply(exp: string): any;
2728
$apply(exp: Function): any;

modules/angular2/src/upgrade/downgrade_ng2_adapter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ export class DowngradeNg2ComponentAdapter {
160160
}
161161

162162
registerCleanup() {
163-
this.element.bind('$destroy', () => this.viewManager.destroyRootHostView(this.hostViewRef));
163+
this.element.bind('$destroy', () => {
164+
this.componentScope.$destroy();
165+
this.viewManager.destroyRootHostView(this.hostViewRef);
166+
});
164167
}
165168
}
166169

0 commit comments

Comments
 (0)