Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从angular2 nativescript中的可观察数组获取字符串值_Angular_Typescript_Nativescript_Angular2 Nativescript - Fatal编程技术网

从angular2 nativescript中的可观察数组获取字符串值

从angular2 nativescript中的可观察数组获取字符串值,angular,typescript,nativescript,angular2-nativescript,Angular,Typescript,Nativescript,Angular2 Nativescript,我将json数据推送到可观察数组中。我需要从ShowData中获取唯一的地址。这意味着我需要基于位置获取地址值的字符串类型 ShowData.ts: class ShowData{ constructor(public id:number, public name:string, public address:string, public code:string) { } } private arrList: ObservableArray<ShowData>

我将json数据推送到可观察数组中。我需要从ShowData中获取唯一的地址。这意味着我需要基于位置获取地址值的字符串类型

ShowData.ts:

 class ShowData{

  constructor(public id:number, public name:string, public address:string, public code:string) {
  }

 }
  private arrList: ObservableArray<ShowData> = new ObservableArray<ShowData>();

openData(pos : number){    --->listview item position


   let getValue: any = this.arrList.get(pos);  // this is not worked


}
ts文件:

 class ShowData{

  constructor(public id:number, public name:string, public address:string, public code:string) {
  }

 }
  private arrList: ObservableArray<ShowData> = new ObservableArray<ShowData>();

openData(pos : number){    --->listview item position


   let getValue: any = this.arrList.get(pos);  // this is not worked


}
private arrList:ObservableArray=new ObservableArray();
openData(位置:编号){->listview项目位置
让getValue:any=this.arrList.get(pos);//这不起作用
}

根据listview项目的位置,我只需要获取arrList地址。

如果需要地址,以下内容将有所帮助

openData(pos : number){    --->listview item position
   let getValue: any = this.arrList[pos].address;
}

如果您想要地址,以下内容将有所帮助

openData(pos : number){    --->listview item position
   let getValue: any = this.arrList[pos].address;
}
可观察数组用于从数组中检索项(而不是
。get

可观察数组用于从数组中检索项(而不是
。get


ObservaleArray是与RxJS的ObservaleArray和Angular不兼容的NativeScript Observales的一部分。ObservaleArray是与RxJS的Observales和Angular不兼容的NativeScript Observales的一部分。
this.arrList.getItem(pos.address
;)在控制台中,我无法读取未定义的属性地址。console.log(“地址”,getValue);您确定传递到函数中的
pos
有效吗?ie你确定
pos
不大于数组长度吗?我会检查并让你知道。@Nicolaseurdu你的评论
this.arrList.getItem(pos).address
写得很好。谢谢你的回答。你能将此作为答案发布吗?
this.arrList.getItem(pos.address
;)在控制台中,我无法读取未定义的属性地址。console.log(“地址”,getValue);您确定传递到函数中的
pos
有效吗?ie你确定
pos
不大于数组长度吗?我会检查并让你知道。@Nicolaseurdu你的评论
this.arrList.getItem(pos).address
写得很好。谢谢你的回答。你能把这个贴出来作为答案吗?