逗人, 我使用nativescript與angular2並嘗試使用SegmentedBar它正常工作與我,但我需要觸發的selectedIndex我的HTML:Nativescript angular2無法訪問Segmentedbar的selectedIndex
<SegmentedBar class="tabs" [items]="items" [(ngModel)]="selectedIndex" selectedBackgroundColor="#000" (selectedIndexChanged)="SegmentChanged(selectedIndex)" #tabs></SegmentedBar>
和我組件是:
selectedIndex: number;
constructor(@Inject(Page) private _page: Page){
this.selectedIndex = 0;
}
public SegmentChanged(b) {
console.log(b) // it gives me the old value not the current value
}
該代碼給我舊的selectIndex值不是活動的。 我也試過了代碼片段: http://www.nativescriptsnacks.com/snippets/2016/06/22/angular-segmentedbar.html 但它不適合我,因爲:
@ViewChild("tabs") tabs: ElementRef; // console.log(this.tabs); return undefined
如果任何一個能幫助或者給我一個工作片段。 謝謝。
鏈路只答案都望而卻步的SO。請直接在您的答案中發佈相關內容。 –
謝謝@尼古拉它工作正常。 –