Я создал директиву ng-repeat для предоставления списка переключателей и попытался получить доступ к выбранному пользователем значению в контроллере, но значения, которые я получаю, не определены. Это код с платформы servicenow, пожалуйста, дайте мне знать, что случилось.
<div>
<!-- your widget template -->
<div class= "panel panel-default">
<div class="panel-heading">
<h3 class="panel-title" align="center">
Select the options below to make a request:
</h3>
</div>
<body>
<div class="btn-group btn-group-justified">
<div ng-repeat="item in data.items">
<input type="radio"
name="item"
data-ng-model="$parent.item"
ng-checked="$first"
id="{{::item.name}}"
ng-value="{{::item.sys_id}}">
<label class="form-check-label" align="center">
<h5> {{::item.name}}</h5>
</label>
</div>
<div>
<input type="radio"
name="select-service"
ng-model="result"
id="service3"
ng-value="'Other'">
<label class="form-check-label" align="center">
<h5> OTHER</h5>
</label>
</div>
</div>
<div ng-if="result=='Other'" class="md-block" style="width: 600px">
<span>Select the item that you are interested</span>
<sn-record-picker id="item1"
field="location"
table="'u_sc_cat_item_ext'"
display-fields="'name,sc_catalogs'"
value-field="'sys_id'"
search-fields="'name'"
default-query="data.queryString">
</sn-record-picker>
</div>
<br>
<br>
<button type="button"
class="btn btn-primary btn-lg"
id="proceed1"
ng-click="RequestService()">Proceed</button>
</body>
</div>
</div>
Контроллер:
function ($scope,
$element,
$window,
$location,
$rootScope,
$timeout,
snAttachmentHandler,
$http,
spUtil,
userPreferences,
$filter,
i18n,
$uibModal) {
/* widget controller */
var c = this;
$scope.RequestService = function() {
$scope.data.action = $scope.item;-->>getting undefined value
c.data.item1 = $('#item1').select2('val');
$scope.server.update().then(function() {
$scope.data.action = undefined;
$scope.data.message = "";
if ($scope.result == undefined) {
$window.alert("RadioButton not checked.");
//window.location.href='?id=hhs_request_page';
}
else {
window.location.href = $scope.data.href;
}
});
};
}