gpt4 book ai didi

javascript - 如何在 x-editable angularjs 的选择下拉列表中获取所选值

转载 作者:行者123 更新时间:2023-12-03 10:33:45 25 4
gpt4 key购买 nike

我在 angularjs 中使用 x-editable。

当我提交选择时。

我没有获得文档中给出的 $data 的新值

这是 fiddle http://jsfiddle.net/NfPcH/7014/

脚本:

var app = angular.module("app", ["xeditable", "ngMockE2E"]);

app.run(function(editableOptions) {
editableOptions.theme = 'bs3';
});

app.controller('Ctrl', function($scope, $q, $http) {
$scope.items = ['a','b','c'];
$scope.user = {
id: 1,
name: 'a'
};

$scope.updateUser = function(data) {
alert(data);
$scope.console = data;
return $http.post('/updateUser', {id: $scope.user.id, name: data});
};
});

// mock `/updateUser` request
app.run(function($httpBackend) {
$httpBackend.whenPOST(/\/updateUser/).respond(function(method, url, data) {
data = angular.fromJson(data);
if(data.name === 'error') {
return [500, 'Error message'];
} else {
return [200, {status: 'ok'}];
}
});
});

谁能帮我,我如何获得更新后的值?

最佳答案

你的问题是你试图在你的html中读取s.text,但你的数组中没有文本键!

改变....

ng-options="s.text as s for s in items"

ng-options="s for s in items"

而且它似乎有效。

http://jsfiddle.net/v983ryrk/1/

关于javascript - 如何在 x-editable angularjs 的选择下拉列表中获取所选值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29098539/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com