【发布时间】:2016-07-28 00:19:48
【问题描述】:
亲爱的, 我正在使用带有 angular2 的 nativescript 并尝试使用 SegmentedBar 它对我来说很好,但我需要触发我的 HTML 的 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 值而不是活动的值。 我也试过那个代码sn-p: http://www.nativescriptsnacks.com/snippets/2016/06/22/angular-segmentedbar.html 但它对我不起作用,因为:
@ViewChild("tabs") tabs: ElementRef; // console.log(this.tabs); return undefined
如果有人可以帮助或给我一个工作的sn-p。 谢谢。
【问题讨论】:
标签: angular telerik nativescript