我有一個ng-repeat
,我試圖添加一個模式,將相同的範圍變量傳遞給模態窗口。我能夠打開模式窗口,但是ng-repeat的範圍值不會顯示在模式內部。希望我的代碼更好解釋。這是我到目前爲止有:ng-repeat中使用模態窗口
<div ng-controller="CustomerController">
<div ng-repeat="customer in customers">
<button class="btn btn-default" ng-click="open()">{{ customer.name }}</button>
<!--MODAL WINDOW-->
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<h3>The Customer Name is: {{ customer.name }}</h3>
</div>
<div class="modal-body">
This is where the Customer Details Goes<br />
{{ customer.details }}
</div>
<div class="modal-footer">
</div>
</script>
</div>
</div>
控制器:
app.controller('CustomerController', function($scope, $timeout, $modal, $log, customerServices) {
$scope.customers= customerServices.getCustomers();
// MODAL WINDOW
$scope.open = function() {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
});
};
});
上述打開模式窗口。但是,來自ng-repeat的客戶詳細信息(例如{{customer.name}}不會傳遞到模式窗口中。我的控制器有問題嗎?
我想在看角Bootrap UI例如這裏之後創建此:http://angular-ui.github.io/bootstrap/
編輯:
這裏是一個的jsfiddle樣本:http://jsfiddle.net/Alien_time/8s9ss/3/
完美!它在通過'open()'傳遞'customer'範圍並且然後將'customer'數據返回到'ModalInstanceCtrl'來處理之後起作用。謝謝你!這正是我遇到的問題。乾杯! – Neel