角度uiモーダルコントローラの内部で関数を定義しようとすると、デフォルトで$ scope.okと$ scope.cancelの2つの関数が見つかりました。角度uiモーダルコントローラ内で関数を定義する方法
myapp.controller('ModalInstanceCtrl', function ($scope,$location,$uibModalInstance, items) {
$scope.items = items;
$scope.selected = {
item: $scope.items[0]
};
$scope.ok = function() {
$uibModalInstance.close($scope.selected.item);
alert("redirection");
$location.path('/questionnaire');
};
$scope.closeListeChoix = function() {
$uibModalInstance.close($scope.selected.item);
};
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
$scope.deleteChoix=function($index)
{
alert("supp")
$scope.items.splice($index, 1);
};
});
と、ここで私は、コントローラ
$scope.ListeChoixOneQuestion=[];
$scope.openListeChoix = function ($index) {
$scope.ListeChoixOneQuestion=$scope.questions[$index].choix ;
console.log("*********** choix de la question **********")
for(var i=0;i<$scope.ListeChoixOneQuestion.length;i++){
console.log("choix : "+$scope.ListeChoixOneQuestion[i].designation);
}
var modalInstance = $uibModal.open({
animation: $scope.animationsEnabled,
templateUrl: 'listeOfChoix.html',
controller: 'ModalInstanceCtrl',
resolve: {
items: function() {
return $scope.ListeChoixOneQuestion;
}
}
});
とこれをモーダルする項目のLISTEを送る:アイテムは、そのコントローラ へのセンドこの私の角度UIモーダルコントローラコード項目のリストを形成します私のHTMLコード私は関数の呼び出しを呼び出すとき私のNGクリック何でeChoixが起こると、アイテムがアイテム 任意の解決策のリストから削除しませんでした
<div class="modal-body">
<div class="row">
<div class="table-responsive">
<table id="Table2" class="table table-bordered table-striped">
<thead>
<tr>
<th>Designation</th>
<th>Image</th>
<th>Aller à la question</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="choix in items track by $index">
<td>{{choix.designation}}</td>
<td>{{choix.imageUrl}}</td>
<td>{{choix.gotoQuestion}}</td>
<td class="text-center" style="width: 50px;">
<span class="btn btn-danger btn-xs fa fa-remove" style="cursor: pointer;" ng-click="deleteChoix($index);"></span>
</td>
<tr>
</tbody>
</table>
</div>
</div>
</div>
したがって、モーダルの有効範囲で関数を定義しても機能しません。 $ parent.deleteChoix($ index);を試すことができますか。それは単なる小切手ですが、それが機能するかどうかを説明します。 – Walfrat
Thx Manそれは仕事です!私はなぜ理解していないのですか? –