3
我有一個角1.x的MVC設置爲這樣:是否有一種方法可以在ng-repeat中選擇當前範圍?
...
.controller('orderdetailCtrl', ['$scope', 'orderServer', ..., function($scope, orderServer, ...) {
$scope.refundDetail = function(item) {
orderServer.refundDetailDialog(item).result.then(function(data) {
if(data) {
item.refund_info.refund_balance = data;
}
});
}
$scope.refundEdit = function(item) {
orderServer.refundEditDialog(item).result.then(function(data) {
if (data) item.refund_info.refund_balance = data;
});
}
...
}]).controller('refundDetailDialogCtrl', ['$scope', 'orderServer', ..., function($scope, orderServer, ...) {
...
$scope.cancel = function() {
$modalInstance.close($scope.entity.refund_info.refund_balance);
};
}]).factory('orderServer', [..., function(...) {
return {
refundDetailDialog: function(item) {
return $dialogs.create('/.../xxx.modal.html', 'refundDetailDialogCtrl', item, {
size: "lg"
});
},
refundEditDialog: function(item){
return $dialogs.create('/.../xxx.modal.html', 'refundEditCtrl', item);
}
...
}
}]);
現在父頁面有一個像這樣的設置:
<tr ng-repeat="details in entity.refundlist">
...
</tr>
這裏重複的「細節」是$scope.refundDetail
item
,現在上面的代碼工作得很好。出於好奇,我想知道是否可以將OrderServer的承諾中的項目替換爲當前的「細節」範圍(意思是替換item.refund_info.refund_balance = data
)。
到目前爲止我試過:
$scope.refund_info.refund_balance = data;
this.refund_info.refund_balance = data;
refund_info.refund_balance = data;
$scope.details.refund_info.refund_balance = data;
this.details.refund_info.refund_balance = data;
details.refund_info.refund_balance = data;
其中沒有工作。
使用'$ parent。$ scope.' –
你在哪裏使用'refundDetail'?請在HTML –
@ pro.mean中寫下相關的代碼,如果你再次閱讀代碼,你會發現這與這個問題無關。 RefundEdit將數據傳回給RefundDetail,然後將相同的數據傳回給OrderDetail的ng-repeat範圍。 –