ngUpgraders / ng-forward

The default solution for those that want to write Angular 2.x style code in Angular 1.x
411 stars 36 forks source link

Injecting parent component controllers into child #98

Closed timkindberg closed 8 years ago

timkindberg commented 8 years ago

Add the ability to inject ancestor light dom component controllers into child. See http://blog.thoughtram.io/angular/2015/04/09/developing-a-tabs-component-in-angular-2.html for in-depth example. Here's the gist of it:

@Component({ selector: 'tabs' })
export class Tabs {
  addTab(tab: Tab) {  }
}

@Component({ selector: 'tab' })
export class Tab {
  constructor(tabs:Tabs) {
    // tabs is a reference to the first ancestor Tabs component controller
    tabs.addTab(this);
  }
}