angular2 template - Angular 2 property binding -


i have component defined follows:

export class wizardtabs { @input() tabs: any;  @input() selectedstepid: number=0;  selectedindex: number = 0; } 

and template defined follows:

<md-tabs md-border-bottom md-autoselect [selected]="selectedindex"> <template md-tab *ngfor="let tab of tabs" [label]="tab.name" [selectedstepid]="tab.id">   <md-content class="md-padding">     <wizard-tab-content [tabcontent]="tab.stepcomponent"></wizard-tab-content>   </md-content>       </template> </md-tabs> 

i want access tab.id inside component. defined "selectedstepid" input property on component , binding tab.id. throwing exception. know can bind properties datasource template how reverse i.e. bind property template component? in other words how access variable defined in template component?

i think can focus on getting tab component instead of getting 'selectedstepid' property directly. decorator 'viewchildren' may on this.

html file:

<md-tabs>   <md-tab *ngfor="let tab of tabs" [selectedstepid]="tab.id"></md-tab> </md-tabs> 

ts file:

class wizardtabs {    @viewchildren(mdtabcomp) tabs:querylist<mdtabcomp>;    ngafterviewinit() {    this.tabs.toarray().foreach((tab)=>console.log(tab.selectedstepid));   }  } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -