export interface OnDestroy
export interface OnDestroy
exported from angular2/core defined in angular2/src/core/linker/interfaces.ts (line 189)
Implement this interface to get notified when your directive is destroyed.
ngOnDestroy
callback is typically used for any custom cleanup that needs to occur when the
instance is destroyed
Example (live example)
To create a stateful Pipe, you should implement this interface and set the pure
parameter to false
in the PipeMetadata
.
A stateful pipe may produce different output, given the same input. It is likely that a stateful pipe may contain state that should be cleaned up when a binding is destroyed. For example, a subscription to a stream of data may need to be disposed, or an interval may need to be cleared.
Example (live demo)
In this example, a pipe is created to countdown its input value, updating it every 50ms. Because it maintains an internal interval, it automatically clears the interval when the binding is destroyed or the countdown completes.
Invoking {{ 10000 | countdown }}
would cause the value to be decremented by 50,
every 50ms, until it reaches 0.
Members
ngOnDestroy()
ngOnDestroy()
Not Yet Documented