如何使用 meanjs 在另一个输入字段中绑定下拉字段值?

How to bind drop down field value in another input field using meanjs?

我的Html:-

     <div>
  <label>1. Without array value</label>
  <select ng-model="question"  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.commentText  for item in question.comments">
  </select>
  {{class.commentText}}
  </div>

  <div>
    <input type="text"  ng-model="newclass"  ng-bind="newclass=class"/>
  </div>

输入字段:-

    <div>
    <input type="text"  ng-model="newclass"  ng-bind="newclass=class"/>
  </div>

我的数据 :-

    $scope.questions = [
{
"_id": "59df6c37b6748bc809050699",
"user": {
"_id": "59df6a76b6748bc809050697",
"profileImageURL": "modules/users/client/img/profile/default.png"
},
"__v": 1,
"openeyers": [],
"openeyes": 0,
"upvoters": [],
"upvotes": 0,
"isLiked": false,
"users": [],
"comments": [
{
"created": 1507897712831,
"email": "ms@e21designs.com",
"name": "Maniselvam selvam",
"link": "https://drive.google.com/drive/u/0/folders/0B5c-p1bvkfS9REJHMGhMY1BTV1k",
"commentText": "7A"
}
],
"questionid": "",
"title": "Silver jublie",
"created": "2017-10-12T13:20:55.383Z"
},
{
"_id": "59df6c37b6748bc809050699",
"user": {
"_id": "59df6a76b6748bc809050697",
"displayName": "Maniselvam selvam",
"dob": "1991-05-10T07:00:00.000Z",
"profileImageURL": "modules/users/client/img/profile/default.png"
},
"__v": 1,
"openeyers": [],
"users": [],
"comments": [
{
"created": 1507897712831,
"email": "ms@e21designs.com",
"name": "Maniselvam selvam",
"link": "https://drive.google.com/drive/u/0/folders/0B5c-p1bvkfS9REJHMGhMY1BTV1k",
"commentText": "8A"
}
],
"questionid": "",
"title": "Public School",
"created": "2017-10-12T13:20:55.383Z"
}
]

首先有两种方法

简单地将输入 ng-model 设置为 class.commentText 类似

<input type="text"  ng-model="class.commentText"  />

但是如果您更改输入

,这将导致 select 选项发生变化

第二种方式

在 select 值更改时将值分配给 newClass

 <select style="margin-left: 20px;" ng-model="class" ng-change="newClass=class.commentText"  ng-options="item.commentText  for item in question.comments">
  </select>

<input type="text"  ng-model="newClass"  />

Working demo