* Destroys the current Angular platform and all Angular applications on the page. * Destroys all modules and listeners registered with the platform.
()
| 136 | * Destroys all modules and listeners registered with the platform. |
| 137 | */ |
| 138 | destroy() { |
| 139 | if (this._destroyed) { |
| 140 | throw new RuntimeError( |
| 141 | RuntimeErrorCode.PLATFORM_ALREADY_DESTROYED, |
| 142 | ngDevMode && 'The platform has already been destroyed!', |
| 143 | ); |
| 144 | } |
| 145 | this._modules.slice().forEach((module) => module.destroy()); |
| 146 | this._destroyListeners.forEach((listener) => listener()); |
| 147 | |
| 148 | const destroyListeners = this._injector.get(PLATFORM_DESTROY_LISTENERS, null); |
| 149 | if (destroyListeners) { |
| 150 | destroyListeners.forEach((listener) => listener()); |
| 151 | destroyListeners.clear(); |
| 152 | } |
| 153 | |
| 154 | this._destroyed = true; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Indicates whether this instance was destroyed. |