Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/core_dom/block_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class BlockFactory {
NgAnnotation annotation = ref.annotation;
var visibility = _elementOnly;
if (ref.annotation is NgController) {
scope = scope.createChild({});
scope = scope.createChild(new PrototypeMap(scope.context));
nodeModule.value(Scope, scope);
}
if (ref.annotation.visibility == NgDirective.CHILDREN_VISIBILITY) {
Expand Down
31 changes: 30 additions & 1 deletion test/core_dom/compiler_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ main() => describe('dte.compiler', () {
..type(LocalAttrDirective)
..type(OneOfTwoDirectives)
..type(TwoOfTwoDirectives)
..type(MyController);
..type(MyController)
..type(MyParentController)
..type(MyChildController);
return (Injector _injector) {
injector = _injector;
$compile = injector.get(Compiler);
Expand Down Expand Up @@ -541,6 +543,17 @@ main() => describe('dte.compiler', () {
rootScope.apply();
expect(log.result()).toEqual('IncludeTransclude; SimpleTransclude');
})));

it('should expose a parent controller to the scope of its children', inject((TestBed _) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this test meant to fail prior to the fix? I tested it in a version as far back as 0.9.5+2 and it works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you go back one commit from this one then it fails.


var element = _.compile('<div my-parent-controller>' +
' <div my-child-controller>{{ my_parent.data() }}</div>' +
'</div>');

rootScope.apply();

expect(element.text).toContain('my data');
}));
});


Expand All @@ -557,6 +570,22 @@ main() => describe('dte.compiler', () {
});


@NgController(
selector: '[my-parent-controller]',
publishAs: 'my_parent'
)
class MyParentController {
data() {
return "my data";
}
}

@NgController(
selector: '[my-child-controller]',
publishAs: 'my_child'
)
class MyChildController {}

@NgComponent(
selector: 'tab',
visibility: NgDirective.DIRECT_CHILDREN_VISIBILITY)
Expand Down
1 change: 0 additions & 1 deletion test/directive/ng_a_spec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ main() {
expect(_.rootScope.context['event'] is dom.UIEvent).toEqual(true);
window.location.href = '#';
_.rootScope.context['url'] = '#url';
print(_.rootElement.outerHtml);
_.rootScope.apply();
_.triggerEvent(_.rootElement, 'click', 'MouseEvent');
expect(window.location.href.endsWith("#url")).toEqual(true);
Expand Down