Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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
Angular Object.key-检索,仅从对象获取一个属性_Angular_Object_Properties - Fatal编程技术网

Angular Object.key-检索,仅从对象获取一个属性

Angular Object.key-检索,仅从对象获取一个属性,angular,object,properties,Angular,Object,Properties,如何从对象中仅检索一个属性 在这个例子中,我有两个属性:name和id <div *ngFor="let post of objectKeys(_postArrayMatch.team1)"> Team1: {{ _postArrayMatch.team1[post]}} </div> 团队1:{{{u postArrayMatch.Team1[post]} 我想排除id,如何仅显示name属性 我试着做这样的事,但没用 <di

如何从对象中仅检索一个属性

在这个例子中,我有两个属性:name和id

   <div *ngFor="let post of objectKeys(_postArrayMatch.team1)">
      Team1: {{ _postArrayMatch.team1[post]}}
    </div>

团队1:{{{u postArrayMatch.Team1[post]}
我想排除id,如何仅显示name属性

我试着做这样的事,但没用

   <div *ngFor="let post of objectKeys(_postArrayMatch.team1)">
    Team1: {{ _postArrayMatch.team1[post].name}} 
 </div>

Team1:{{{u postArrayMatch.Team1[post].name}
作为回应,我只是空着

第1组:


第1组:

如果只想显示一个元素,请不要使用
*ngFor
。ngFor用于在iterable中的多个元素上循环

<div>
  Team1: {{ _postArrayMatch.team1.name}}
</div>

团队1:{{{u postArrayMatch.Team1.name}

objectKeys函数的功能以及postArrayMatch.team1的功能是什么?在components.ts-
objectKeys=Object.keys中`
\u postArrayMatch.team1
具有
team1:{name:string;id:number;}那么如何在不循环的情况下检索数据?