我使用Mobile Angular UI并且无法弄清楚如何将值传递给模态。
//按钮
此按钮位于ng-repeat="item in vm.items"
内,需要item
以某种方式传递给模态。
<button class="btn btn-danger pull-right" ui-turn-on="modal">Remove</button>
//模态
<div class="modal scrollable-content section" ui-if='modal' ui-state='modal'>
<div class="modal-backdrop in"></div>
<div class="modal-dialog">
<div class="modal-content">
<form role="form" name="note" autocomplete="off">
<div class="modal-header">
<button class="close"
ui-turn-off="modal">×</button>
<h4 class="modal-title">Are you sure?</h4>
</div>
<div class="modal-body">
<p>Are you sure you'd like to remove this item?</p>
</div>
<div class="modal-footer">
<button ui-turn-off="modal" class="btn btn-default">Cancel</button>
<button type="submit" ng-click="vm.remove(item); Ui.turnOff('modal')" class="btn btn-primary">Remove</button>
</div>
</form>
</div>
</div>
</div>
</div>
答案 0 :(得分:1)
您可以使用值编写html标记(item)属性并读取值
var id = item.attributes ['data-id']。value;
答案 1 :(得分:0)
on button click, you also call a function like
<button class="btn btn-danger pull-right" ui-turn-on="modal"
ng-click="setItemID(item.itemID)">Remove</button>
And then create the setItemID(itemID) function into the angularjs controller
and put the itemID into a scope variable.
When user will click on the remove button, the setItemID function will be
called and the itemId will be assigned into the scope. Now at the time when
user click "Yes i want to remove this item", then use that defined itemID.
Hope you get your solution. If still have any problem then lets comment.