Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

feat(dialog): controller should support AngularJS 1.6 lifecycle events #10567

@smcardle

Description

@smcardle

The Controller attached to an $mdDialog does not honour the angularjs lifecycle events such as $onInit and $onDestroy.

This causes issues when working towards migration of our project to Angular (2/4 etc).

The issue here is that currently event listeners are registered against the $scope via $scope.$on in the $mdDialog controller.

In preparation for migration / upgrade of a significant project towards Angular (2) we are undertaking re-engineering towards Typescript / ES6 classes etc and are removing all references to $scope and $rootScope in the process. As part of this process we have introduced a new EventEmitter framework for registering and subscribing to events through the application.

All of our 'non-$mdDialog' controllers and services are able to take advantage of the Angular 1.6 $onDestroy lifecycle methods as a place to unregister these event handlers.

However, $mdDialog does not honour these lifecycle methods and without the use of $scope. There is NO WAY to deregister these events in a common way, which then causes memory leaks.

We can of course recognize when an $mdDialog is dismissed using its various close handlers but this is messy and requires more thought and discipline on behalf of our developers, a different train of thought is needed, resulting in this not always being done or only partially done. i.e. on the OK / continue but being missed on the close / cancel.

It would be a big help for teams like ours looking at migrating away from the AngularJS 1.x stack if the angular-material team also honoured the AngularJS lifecycle events thus allowing us to use the $onDestroy as common solution for deregistering event handlers.

Regards

Steve

Metadata

Metadata

Assignees

Labels

P3: importantImportant issues that really should be fixed when possible.hotlist: ngUpgradeneeds: demoA CodePen demo or GitHub repository is needed to demonstrate the reproduction of the issueneeds: feedbackThe issue creator or community need to respond to questions in this issueresolution: fixedtype: enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions