【发布时间】:2017-11-04 19:51:20
【问题描述】:
我正在尝试将值作为下拉列表或选择字段获取,它们位于
comments数组中。我正在尝试
comments对象数组commentText在drop down中的值,我该如何在ng-option中执行此操作? My Plunker
例如:
我首先做了下拉
ng-option,没有像ng-options="item.title for item in questions"这样的数组值。我到底在寻找什么 cmets 对象值数组
[commentText": "7A"]在下拉列表中我该怎么做。我试过
ng-options="item for item.comments.commentText in questions"它不适合我。如何解决?
我的数据:
$scope.questions = [
{
"_id": "59df6c37b6748bc809050699",
"user": {
"_id": "59df6a76b6748bc809050697",
"profileImageURL": "modules/users/client/img/profile/default.png"
},
"__v": 1,
"comments": [
{
"created": 1507897712831,
"email": "ms@e21designs.com",
"name": "Maniselvam selvam",
"link": "https://drive.google.com/drive/u/0/folders/0B5c-p1bvkfS9REJHMGhMY1BTV1k",
"commentText": "7A"
}
],
"questionid": "",
"created": "2017-10-12T13:20:55.383Z"
}
]
我的 HTML:
<label>1. Without array value</label>
<select ng-model="class" ng-options="item.title for item in questions">
</select>
</div>
<div style="margin-top: 11px;">
<label>2. With comments array value</label>
<select style="margin-left: 20px;" ng-model="class" ng-options="item for item.comments.commentText in questions">
</select>
</div>
寻找第二种解决方案是:-
- 我只想如果我们选择问题,cmets 选择只过滤这个问题的 cmets...怎么做...谢谢
【问题讨论】:
-
另一种解决方案?你能描述一下吗?
-
立即查看我的更新答案。
-
@mani 如果你修复了最后的错误也会给你打勾......