angular-cn/public/docs/js/latest/api/annotations/onDestroy-const.jade

25 lines
724 B
Plaintext

.l-main-section
h2 onDestroy <span class="type">variable</span>
p.location-badge.
exported from <a href='../annotations'>angular2/annotations</a>
defined in <a href="https://github.com/angular/angular/tree/3a0410a/modules/angular2/src/core/annotations_impl/annotations.ts#L1019-L1019">angular2/src/core/annotations_impl/annotations.ts (line 1019)</a>
:markdown
Notify a directive whenever a <a href='View-var.html'><code>View</code></a> that contains it is destroyed.
## Example
```
@Directive({
...,
lifecycle: [onDestroy]
})
class ClassSet {
onDestroy() {
// invoked to notify directive of the containing view destruction.
}
}
```