У меня есть функция boostrap-ui modal inorder, чтобы ввести некоторые данные. Я создал шаблон для модального и контроллера. Я хочу иметь возможность переходить от одного элемента к другому по таблице с помощью клавиатуры. Я хочу, чтобы перемещаться по радио коробки В нижней строке, я хочу, возможность переключения между radioboxes с помощью клавиатуры: клавиши со стрелкамиконтроль клавиатуры над таблицей ng-repeat с радио-ящиками
Моя таблица выглядит следующим образом
Этот код выглядит так:
modal.html
<div class="modal-header">
<h3 id="" class="modal-title">
<i id="exclamation-triangle" class="fa fa-exclamation-triangle" ng-class="response.status != '200'?'':'hide-content'"></i>
<i id="server" class="fa fa-server" ng-class="response.status == '200'?'':'hide-content'"></i>
<span id="modal-title-content" ng-bind="message==''&&response.status == '200'?'Results':'Warning'"></span>
</h3>
</div>
<div class="modal-body">
<div id="content" ng-class="response.status == '200'?'':'hide-content'">
<table id="content_table" class="table-responsive" cellpadding="10" cellspacing="10" border="1">
<tr>
<th></th>
<th>Id</th>
<th>Source</th>
<th>IsValid</th>
<th>Sampling Date</th>
</tr>
<tr ng-repeat="item in collection track by $index">
<td>
<input class="dga_radio" id="dga-radio-{{$index}}" type="radio" name="dga" value="{{$index}}" ng-model="selectedDga.index" />
<label for="dga-radio-{{$index}}"><span></span></label>
</td>
<td ng-repeat="(key,value) in item track by $index">
{{value}}
</td>
</tr>
</table>
</div>
<div id="warning-msg-container" ng-class="response.status != '200'?'':'hide-content'">
<span id="warning-msg">{{message}}</span>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="ok()" ng-disabled="selectedDga.index == '-1'">OK</button>
<button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
</div>
контроллеры
app.controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, response, errormsg) {
$scope.response = response;
$scope.message = errormsg;
$scope.collection = $scope.response.data;
$scope.selectedDga = {
index: '-1'
}
//ok action
$scope.ok = function() {
console.log('$scope.selectedDga.index', $scope.selectedDga.index);
$uibModalInstance.close($scope.collection[$scope.selectedDga.index]);
};
//cancel action
$scope.cancel = function() {
$uibModalInstance.dismiss('cancel');
};
});
/**
* Analytics Summary CTRL
**/
app.controller('AnalyticsSummaryCTRL', ['$scope','dataFactory' ,'$uibModal', function ($scope,dataFactory,$uibModal) {
const warning_message_one = "Start date and end date values are invalid !";
const warning_message_two = "Start date and end date are required !";
const warning_message_third = "Start date is required !";
const warning_message_four = "End date is required !";
/**
* open modal popup
**/
$scope.open = function (size) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: 'Templates/modal.html',
controller: 'ModalInstanceCtrl',
size: size,
resolve: {
errormsg: function() {
var startDate = $("#datepicker-start").val();
var endDate = $("#datepicker-end").val();
if((angular.isDefined(startDate) && startDate != '') &&
(angular.isDefined(endDate) && (endDate != ''))) {
if (endDate < startDate)
return warning_message_one;
return '';
}else if((!angular.isDefined(startDate) || startDate == '') &&
(!angular.isDefined(endDate) || (endDate == ''))) {
return warning_message_two;
}
else if (!angular.isDefined(startDate) || startDate == '') {
return warning_message_third;
}
else {
return warning_message_four;
}
},
response: function() {
var startDate = $("#datepicker-start").val();
var endDate = $("#datepicker-end").val();
return (dataFactory.getDGAList((angular.isDefined(startDate)) ? startDate : '',
(angular.isDefined(endDate)) ? endDate : ''))
.then(function successCallback(response) {
return response
}, function errorCallback(response) {
return response;
});
}
}
});
modalInstance.result.then(function (selected) {
$scope.selected = selected;
(dataFactory.getDGASummary((angular.isDefined($scope.selected) ? $scope.selected["Id"] : '')))
.then(function successCallback(response) {
console.log('success callback');
generateSummaryData(response)
}, function errorCallback(response) {
console.log('error callback');
});
}, function() {
console.log('Modal dismissed at: ' + new Date());
});
}
почему не используется нг-изменения на радио-кнопок. Кстати, если я изменю выбранныйDga.index, это не значит, что моя кнопка будет меняться визуально. – Brk
не работает, я пробовал. – Brk
thx за советом. Я опубликую полный ответ. – Brk