angular2-polyfill icon indicating copy to clipboard operation
angular2-polyfill copied to clipboard

Add possibility to inject parent components

Open SamVerschueren opened this issue 9 years ago • 0 comments

An example of this is the TabsComponent where the child component gets a reference to the parent component. I don't directly have an idea on how to do this except that it should pass in the $ctrl property of the parent component.

This is how it can be achieved at the moment

@Component
class TabsComponent {
     doSomething() {

     }
}
@Component
class TabComponent {

     private tabsComponent: TabsComponent;

     constructor(@Inject('$scope') scope) {
          this.tabsComponent = scope.$parent.$ctrl;
     }

     ngOnInit() {
          this.tabsComponent.doSomething(this);
     }
}

SamVerschueren avatar Mar 15 '16 19:03 SamVerschueren