diff --git a/lib/core_dom/block_factory.dart b/lib/core_dom/block_factory.dart
index d97d566c4..ccde9117d 100644
--- a/lib/core_dom/block_factory.dart
+++ b/lib/core_dom/block_factory.dart
@@ -204,7 +204,7 @@ class BlockFactory {
var removeWatcher;
removeWatcher = scope.$watch(() {
removeWatcher();
- scope.$evalAsync(() => controller.attach());
+ controller.attach();
});
}
if (controller is NgDetachAware) {
diff --git a/test/core_dom/compiler_spec.dart b/test/core_dom/compiler_spec.dart
index 1cf4b9259..d71bf79c1 100644
--- a/test/core_dom/compiler_spec.dart
+++ b/test/core_dom/compiler_spec.dart
@@ -423,21 +423,25 @@ main() => describe('dte.compiler', () {
it('should fire onTemplate method', async(inject((Logger logger, MockHttpBackend backend) {
backend.whenGET('some/template.url').respond('
WORKED
');
var scope = $rootScope.$new();
- var element = $('');
+ scope['isReady'] = 'ready';
+ scope['logger'] = logger;
+ var element = $('{{logger("inner")}}');
$compile(element)(injector.createChild([new Module()..value(Scope, scope)]), element);
expect(logger).toEqual(['new']);
expect(logger).toEqual(['new']);
$rootScope.$digest();
- expect(logger).toEqual(['new', 'attach:ready']);
+ expect(logger).toEqual(['new', 'attach:@ready; =>ready', 'inner']);
+ logger.clear();
backend.flush();
microLeap();
- expect(logger).toEqual(['new', 'attach:ready', 'templateLoaded', scope.shadowRoot]);
+ expect(logger).toEqual(['templateLoaded', scope.shadowRoot]);
+ logger.clear();
scope.$destroy();
- expect(logger).toEqual(['new', 'attach:ready', 'templateLoaded', scope.shadowRoot, 'detach']);
+ expect(logger).toEqual(['detach']);
expect(element.textWithShadow()).toEqual('WORKED');
})));
});
@@ -714,19 +718,23 @@ class LogComponent {
@NgComponent(
selector: 'attach-detach',
templateUrl: 'some/template.url',
- map: const { 'value': '@value' }
+ map: const {
+ 'attr-value': '@attrValue',
+ 'expr-value': '<=>exprValue'
+ }
)
class AttachDetachComponent implements NgAttachAware, NgDetachAware, NgShadowRootAware {
Logger logger;
Scope scope;
- String value = 'too early';
+ String attrValue = 'too early';
+ String exprValue = 'too early';
AttachDetachComponent(Logger this.logger, TemplateLoader templateLoader, Scope this.scope) {
logger('new');
templateLoader.template.then((_) => logger('templateLoaded'));
}
- attach() => logger('attach:$value');
+ attach() => logger('attach:@$attrValue; =>$exprValue');
detach() => logger('detach');
onShadowRoot(shadowRoot) {
scope.$root.shadowRoot = shadowRoot;