<tr ng-repeat="user in users" ng-class="{'selected': user.AdmissionID == selectedRow}" ng-click="setClickedRow(user.AdmissionID)">
    <td>{{user.AdmissionID}}</td>
    <td>{{user.AdmissionNo}}</td>
    <td>{{user.AdmissionDateTime}}</td>
    <td>{{user.Lname}}, {{user.Fname}} {{user.Mname}} </td>
    <td>{{user.Admission}}</td>
    <td>{{user.AdmissionType}}</td>
    <td>{{user.Gender}}</td>
    <td>{{user.Address}}</td>
</tr>


我正在尝试将user.AdmissionID分配为文本框中的值。可能吗?

最佳答案

是的,请使用ng-model将您的值绑定到文本框

演示



var app =angular.module('testApp',[]);
app.controller('testCtrl',function($scope){

$scope.users = [{
  "AdmissionID": "Klimovsk",
  "AdmissionNo": 23
}, {
  "AdmissionID": "Shalakusha",
   "AdmissionNo": 23
}];

$scope.setClickedRow =function(user){
  $scope.selectedAdmissionID = user.AdmissionID;
}

});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="testApp" ng-controller="testCtrl">
 <table>
 <tr ng-repeat="user in users"  ng-click="setClickedRow(user)">
    <td>{{user.AdmissionID}}</td>
    <td>{{user.AdmissionNo}}</td>
</tr>
 <table>
   <input type="text" ng-model="selectedAdmissionID">
 </body>

09-10 11:53
查看更多