我想将登录用户单击userName的userNamesa 列表中的传递给twitter bootstrap modal。我正在与 angularjs* 一起使用 grails ,其中数据是通过 angularjs 呈现的。 ***
userName
modal
我的grails视图页面encouragement.gsp是
encouragement.gsp
<div ng-controller="EncouragementController"> <g:render template="encourage/encouragement_modal" /> <tr ng-cloak ng-repeat="user in result.users"> <td>{{user.userName}}</rd> <td> <a class="btn btn-primary span11" href="#encouragementModal" data-toggle="modal"> Encourage </a> </td> </tr>
我的encourage/_encouragement_modal.gsp是
encourage/_encouragement_modal.gsp
<div id="encouragementModal" class="modal hide fade"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Confirm encouragement?</h3> </div> <div class="modal-body"> Do you really want to encourage <b>{{aModel.userName}}</b>? </div> <div class="modal-footer"> <button class="btn btn-info" ng-click="encourage('${createLink(uri: '/encourage/')}',{{aModel.userName}})"> Confirm </button> <button class="btn" data-dismiss="modal" aria-hidden="true">Never Mind</button> </div> </div>
所以,我怎么能传递userName到encouragementModal?
encouragementModal
我ng-click在 鼓励 按钮上打电话给angularjs控制器,
ng-click
<tr ng-cloak ng-repeat="user in result.users"> <td>{{user.userName}}</rd> <td> <a class="btn btn-primary span11" ng-click="setUsername({{user.userName}})" href="#encouragementModal" data-toggle="modal"> Encourage </a> </td> </tr>
我设置userName的encouragementModal从angularjs控制器。
/** * Encouragement controller for AngularJS * * @param $scope * @param $http * @param encouragementService */ function EncouragementController($scope, $http, encouragementService) { /** * set invoice number */ $scope.setUsername = function (username) { $scope.userName = username; }; } EncouragementController.$inject = [ '$scope', '$http', 'encouragementService' ];
我提供了一个place(userName)来从angularjs控制器获取价值encouragementModal。
<div id="encouragementModal" class="modal hide fade"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3>Confirm encouragement?</h3> </div> <div class="modal-body"> Do you really want to encourage <b>{{userName}}</b>? </div> <div class="modal-footer"> <button class="btn btn-info" ng-click="encourage('${createLink(uri: '/encourage/')}',{{userName}})"> Confirm </button> <button class="btn" data-dismiss="modal" aria-hidden="true">Never Mind</button> </div> </div>