得到观察到阵列中angular2 nativescript
字符串值,我把JSON DATAS到观察的array.I需要得到仅从ShowData.That地址意味着只是一个字符串类型,我需要得到一个基于位置的地址值。得到观察到阵列中angular2 nativescript
ShowData.ts:
class ShowData{
constructor(public id:number, public name:string, public address:string, public code:string) {
}
}
TS文件:
private arrList: ObservableArray<ShowData> = new ObservableArray<ShowData>();
openData(pos : number){ --->listview item position
let getValue: any = this.arrList.get(pos); // this is not worked
}
基础上ListView项的位置,我需要得到只有arrList地址。
可观测阵列使用.getItem
从阵列(未.get
)检索项
openData(pos : number){
let getValue: any = this.arrList.getItem(pos).address;
}
如果您需要的地址,下面将帮助
openData(pos : number){ --->listview item position
let getValue: any = this.arrList[pos].address;
}
'this.arrList.getItem(POS).address';) –
在控制台我越来越看不懂的未定义的属性格式的地址。 console.log(“address”,getValue); – Steve
你确定了'pos'你传递给函数是有效的?即你确定'pos'不是大于数组长度吗? – mast3rd3mon
ObservaleArray是NativeScripts观测量的一部分,不属于与RxJS的Observables和Angular兼容。 – theOriginalJosh