feat(core): support ngOnDestroy on providers of a directive.

Such providers also become eager as they will be instantiated
anyways on destruction.
This commit is contained in:
Tobias Bosch
2016-08-02 01:37:42 -07:00
parent ff3b71f7b3
commit c161ed415d
10 changed files with 87 additions and 42 deletions

View File

@ -9,6 +9,7 @@
import {CompileDirectiveMetadata} from '../compile_metadata';
import {ListWrapper, StringMapWrapper} from '../facade/collection';
import {StringWrapper, isBlank, isPresent} from '../facade/lang';
import {identifierToken} from '../identifiers';
import * as o from '../output/output_ast';
import {BoundEventAst, DirectiveAst} from '../template_parser/template_ast';
@ -134,8 +135,9 @@ export function collectEventListeners(
compileElement, hostEvent.target, hostEvent.name, eventListeners);
listener.addAction(hostEvent, null, null);
});
ListWrapper.forEachWithIndex(dirs, (directiveAst, i) => {
var directiveInstance = compileElement.directiveInstances[i];
dirs.forEach((directiveAst) => {
var directiveInstance =
compileElement.instances.get(identifierToken(directiveAst.directive.type));
directiveAst.hostEvents.forEach((hostEvent) => {
compileElement.view.bindings.push(new CompileBinding(compileElement, hostEvent));
var listener = CompileEventListener.getOrCreate(