* Destroys the current Angular platform and all Angular applications on the page. * Destroys all modules and listeners registered with the platform.
()
| 121 | * Destroys all modules and listeners registered with the platform. |
| 122 | */ |
| 123 | destroy() { |
| 124 | if (this._destroyed) { |
| 125 | throw new RuntimeError( |
| 126 | RuntimeErrorCode.PLATFORM_ALREADY_DESTROYED, |
| 127 | ngDevMode && 'The platform has already been destroyed!', |
| 128 | ); |
| 129 | } |
| 130 | this._modules.slice().forEach((module) => module.destroy()); |
| 131 | this._destroyListeners.forEach((listener) => listener()); |
| 132 | |
| 133 | const destroyListeners = this._injector.get(PLATFORM_DESTROY_LISTENERS, null); |
| 134 | if (destroyListeners) { |
| 135 | destroyListeners.forEach((listener) => listener()); |
| 136 | destroyListeners.clear(); |
| 137 | } |
| 138 | |
| 139 | this._destroyed = true; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Indicates whether this instance was destroyed. |