This repository was archived by the owner on Feb 22, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ class BlockFactory {
120
120
NgAnnotation annotation = ref.annotation;
121
121
var visibility = _elementOnly;
122
122
if (ref.annotation is NgController ) {
123
- scope = scope.createChild ({} );
123
+ scope = scope.createChild (new PrototypeMap (scope.context) );
124
124
nodeModule.value (Scope , scope);
125
125
}
126
126
if (ref.annotation.visibility == NgDirective .CHILDREN_VISIBILITY ) {
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ main() => describe('dte.compiler', () {
19
19
..type (LocalAttrDirective )
20
20
..type (OneOfTwoDirectives )
21
21
..type (TwoOfTwoDirectives )
22
- ..type (MyController );
22
+ ..type (MyController )
23
+ ..type (MyParentController )
24
+ ..type (MyChildController );
23
25
return (Injector _injector) {
24
26
injector = _injector;
25
27
$compile = injector.get (Compiler );
@@ -541,6 +543,17 @@ main() => describe('dte.compiler', () {
541
543
rootScope.apply ();
542
544
expect (log.result ()).toEqual ('IncludeTransclude; SimpleTransclude' );
543
545
})));
546
+
547
+ it ('should expose a parent controller to the scope of its children' , inject ((TestBed _) {
548
+
549
+ var element = _.compile ('<div my-parent-controller>' +
550
+ ' <div my-child-controller>{{ my_parent.data() }}</div>' +
551
+ '</div>' );
552
+
553
+ rootScope.apply ();
554
+
555
+ expect (element.text).toContain ('my data' );
556
+ }));
544
557
});
545
558
546
559
@@ -557,6 +570,22 @@ main() => describe('dte.compiler', () {
557
570
});
558
571
559
572
573
+ @NgController (
574
+ selector: '[my-parent-controller]' ,
575
+ publishAs: 'my_parent'
576
+ )
577
+ class MyParentController {
578
+ data () {
579
+ return "my data" ;
580
+ }
581
+ }
582
+
583
+ @NgController (
584
+ selector: '[my-child-controller]' ,
585
+ publishAs: 'my_child'
586
+ )
587
+ class MyChildController {}
588
+
560
589
@NgComponent (
561
590
selector: 'tab' ,
562
591
visibility: NgDirective .DIRECT_CHILDREN_VISIBILITY )
You can’t perform that action at this time.
0 commit comments