Angularjs 如何使用ng repeat根据在另一个表中选择的行填充表?

Angularjs 如何使用ng repeat根据在另一个表中选择的行填充表?,angularjs,symfony,twig,Angularjs,Symfony,Twig,我有一个表,用户可以从中选择一个选项,根据这个选项,我应该选择所选的对象并将其填充到另一个表中。。。。(通过调用角度控制器中的api填充用户)。简而言之,我想做的是,要求用户输入一个搜索词,然后根据该关键字检索用户,当用户选择他正在搜索的用户时,我应该在另一个表中显示该用户(用户详细信息) {form_行(form.userKeyword,{'attr':{'ng model':'userKeyword','ng value':'userSelect.id'}}}} 用户Id 全名 电子邮件 电

我有一个表,用户可以从中选择一个选项,根据这个选项,我应该选择所选的对象并将其填充到另一个表中。。。。(通过调用角度控制器中的api填充用户)。简而言之,我想做的是,要求用户输入一个搜索词,然后根据该关键字检索用户,当用户选择他正在搜索的用户时,我应该在另一个表中显示该用户(用户详细信息)

{form_行(form.userKeyword,{'attr':{'ng model':'userKeyword','ng value':'userSelect.id'}}}}
用户Id
全名
电子邮件
电话号码
{{'ng::user.id::'}}
{{'ng::user.name::'}
{{'ng::user.email::'}
{{'ng::user.phone::'}
用户详细信息:
用户Id
全名
电子邮件
电话号码
{{'ng::user.id::'}}
{{'ng::user.name::'}
{{'ng::user.email::'}
{{'ng::user.phone::'}
app.controller('My controller',函数($scope,$http){
$scope.showTable=false;
$scope.showUserDetails=false;
$scope.users=[];
$scope.searchBy=“”;
$scope.keyword=“”;
$scope.userSelect=“”;
$scope.userKeyword=“”;
$scope.OnButtonClick=function(){
$scope.showTable=true;
console.log($scope.searchBy);
var请求=$http({
方法:“获取”,
url:Routing.generate('api\u关键字\u用户'{
“searchBy”:$scope.searchBy,
“关键字”:$scope.keyword,
})
});
请求成功(功能(响应){
$scope.users=响应;
log($scope.users);
});
}
$scope.OnTableSelect=函数(){
$scope.showUserDetails=true;
$scope.showTable=false;
log($scope.userKeyowrd);
log($scope.userSelect);
}

您不能在
元素上使用
ng model
。您可以改为在
上使用
ng click
指令,并将用户作为调用的一部分传递给控制器方法:

<table class="table table-bordered table-hover" ng-show="showTable">
  <tr>
    <th>User Id </th>
    <th>Full name </th>
    <th>E-mail </th>
    <th>Phone Number </th>
  </tr>

  <tr ng-click="OnTableSelect(user)" ng-repeat="user in users track by user.id">
    <td>{{ 'ng::user.id::' }}</td>
    <td>{{ 'ng::user.name::' }}</td>
    <td>{{ 'ng::user.email::' }}</td>
    <td>{{ 'ng::user.phone::' }}</td>
  </tr>

</table>

$scope.OnTableSelect = function(user) {
    $scope.showUserDetails = true;
    $scope.showTable = false;
    console.log(user);
}

用户Id
全名
电子邮件
电话号码
{{'ng::user.id::'}}
{{'ng::user.name::'}
{{'ng::user.email::'}
{{'ng::user.phone::'}
$scope.OnTableSelect=函数(用户){
$scope.showUserDetails=true;
$scope.showTable=false;
console.log(用户);
}