我正在与angular-xeditable radiolist合作。但是,当列表值不是数字时,我的代码无法正常工作。我找到了 -
我使用的是JQuery 3.2.1,bootstrap 3.3.7,angular 1.6.1,angular-xeditable 0.8.0。
在下面的代码中,我提供了一个包含3个案例的简单示例。请帮我解决这个问题。
HTML 的
var app = angular.module("app", ["xeditable"]);
app.run(function(editableOptions) {
editableOptions.theme = 'bs3';
});
app.controller('Ctrl', function($scope, $filter) {
$scope.user = {
status_n: 2,
status_t: 'F',
status_ts: 'G BBB'
};
$scope.statuses_n = [
{value: 1, text: 'Male'},
{value: 2, text: 'Female'}
];
$scope.statuses_t = [
{value: 'M', text: 'Male'},
{value: 'F', text: 'Female'}
];
$scope.statuses_ts = [
{value: 'G AAA', text: 'Gender 1'},
{value: 'G BBB', text: 'Gender 2'}
];
$scope.showStatus_n = function() {
var selected = $filter('filter')($scope.statuses_n, {value: $scope.user.status_n});
return ($scope.user.status_n && selected.length) ? selected[0].text : 'Not set';
};
$scope.showStatus_t = function() {
var selected = $filter('filter')($scope.statuses_t, {value: $scope.user.status_t});
return ($scope.user.status_t && selected.length) ? selected[0].text : 'Not set';
};
$scope.showStatus_ts = function() {
var selected = $filter('filter')($scope.statuses_ts, {value: $scope.user.status_ts});
return ($scope.user.status_ts && selected.length) ? selected[0].text : 'Not set';
};
的JavaScript
searchable: true
});
jsfiddle链接:https://jsfiddle.net/sagarsde/713m56dd/27/