如何使用Angular.js从ng-repeated div中的隐藏输入中获取值

时间:2015-09-29 13:37:12

标签: javascript angularjs angularjs-ng-repeat

我有控制器将数据发送到UI并使用ng-repeat指令映射它们。我想做的事情是将该数据与隐藏的输入形式绑定,并在发生单击事件时将其发送到控制器中的另一个函数中。知道怎么做到这一点? 我的HTML看起来像这样:

<div class="card card-block" ng-repeat="admin in showAdmins">
<h3 class="card-title">{{admin}}</h3>
<input type="hidden" ng-value="{{admin}}" ng-model="username"/>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<button class="btn btn-primary"  ng-click="searchAdmins(username)">SeeProfile</button>
</div>

和控制器:

$scope.searchAdmins = function(username){

    //To do
};

github.users('admins.php').then(function(users){

    $scope.showAdmins = users;
    console.log($scope.showAdmins);

});

2 个答案:

答案 0 :(得分:1)

我想你想这样做:

softlib_PERMS.cmd 2>>AddAccts.log 2>&1
softlib_PERMS.cmd >nul >AddAccts.log

答案 1 :(得分:0)

http://plnkr.co/edit/IzJkvLJoTHLtVzobWPpZ?p=preview

var app = angular.module('app',[]);

app.controller('testctrl',function($ scope){

var users = [

{
  user : 'User1'
}, {
  user : 'User2'
}, {
  user : 'User3'
}

];

$ scope.showAdmins = users;

$ scope.searchAdmins = function(user){

警报(用户);  }

});

HTML

<div  ng-repeat="admin in showAdmins">
<h3 >{{admin.user}}</h3>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<button class="btn btn-primary"  ng-click="searchAdmins(admin.user)">SeeProfile</button>


    

谢谢你, 切塔尼亚