Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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 ng向表单元格重复集合数组不工作_Angular_Mongodb_Mean Stack - Fatal编程技术网

Angular ng向表单元格重复集合数组不工作

Angular ng向表单元格重复集合数组不工作,angular,mongodb,mean-stack,Angular,Mongodb,Mean Stack,我一直在设计一个平均堆栈应用程序。我有以下mongoDB数据 旅馆 { "_id" : ObjectId("5e3c21c03d8d54b35af796ed"), "Hostel" : "The traveler's Lodge", "Rooms" : 23, "Customer" : [ { "_id" : ObjectId("5e3c1e863d8d54b35af796eb"), "name" : "Harry Williams",

我一直在设计一个平均堆栈应用程序。我有以下mongoDB数据

旅馆

{ "_id" : ObjectId("5e3c21c03d8d54b35af796ed"), 
   "Hostel" : "The traveler's Lodge", 
   "Rooms" : 23,  
   "Customer" : [ 
   {   "_id" : ObjectId("5e3c1e863d8d54b35af796eb"), 
       "name" : "Harry Williams", 
       "From" : "United States", 
       "numDays" : 12 
    }] 
}
我一直想把它打印到一张表上。但是,在尝试打印阵列中的数据时,我无法执行此操作。我曾尝试使用ng repeat来执行此操作,但这只会导致表格单元格保持空白

app.component.html

<tr *ngFor="let lodge of hostels>
    ...
    <td ng-repeat="arr in lodge.Customer">{{ arr.name}}</td>
</tr>

您正在尝试混合使用Angular 2+和Angular 1.x
试试这个:

<tr *ngFor="let lodge of hostels>
    ...
    <td *ngFor="let arr of lodge.Customer">{{ arr.name}}</td>
</tr>

你为什么把
ng repeat
(在AngularJS 1.x中使用)和
*ngFor
(在Angular 2+中使用)混合在一起?这不应该是
arr in lodge.Customer
?试试:@Joe谢谢,应该是lodge,我已经编辑了这个问题。谢谢,我已经试过你的例子了。我需要它在同一个td上,但是使用span解决了这个问题。很高兴能帮助您。